summaryrefslogtreecommitdiff
path: root/sv.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-04-21 11:42:43 +0000
committerNicholas Clark <nick@ccl4.org>2007-04-21 11:42:43 +0000
commit4ea561bc94841f378b6950ed75b669dc60767dfa (patch)
tree7a76995aa0b9fd27756ad182df7d997dd06c953c /sv.h
parent25270bc0b7409c7dbdeef1a6ec0b548e2d3e51a1 (diff)
downloadperl-4ea561bc94841f378b6950ed75b669dc60767dfa.tar.gz
Where possible, use SvIV instead of SvIVX, SvNV instead of SvNVX,
SvUV instead of SvUVX, and SvPV* variants instead of SvPVX*. Document that the non-x variants are preferable whenever the expression has no side effects. (Compilers perform common subexression elimination). Likewise SvREFCNT_inc simple variants are valid for all cases apart from expressions with side effects. p4raw-id: //depot/perl@31010
Diffstat (limited to 'sv.h')
-rw-r--r--sv.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/sv.h b/sv.h
index ba873ea5ee..54f319d68e 100644
--- a/sv.h
+++ b/sv.h
@@ -177,9 +177,8 @@ to return a meaningful value, or check for NULLness, so it's smaller
and faster.
=for apidoc Am|SV*|SvREFCNT_inc_simple|SV* sv
-Same as SvREFCNT_inc, but can only be used with simple variables, not
-expressions or pointer dereferences. Since we don't have to store a
-temporary value, it's faster.
+Same as SvREFCNT_inc, but can only be used with expressions without side
+effects. Since we don't have to store a temporary value, it's faster.
=for apidoc Am|SV*|SvREFCNT_inc_simple_NN|SV* sv
Same as SvREFCNT_inc_simple, but can only be used if you know I<sv>
@@ -1550,7 +1549,9 @@ stringified version becoming C<SvPOK>. Handles 'get' magic. See also
C<SvPVx> for a version which guarantees to evaluate sv only once.
=for apidoc Am|char*|SvPVx|SV* sv|STRLEN len
-A version of C<SvPV> which guarantees to evaluate sv only once.
+A version of C<SvPV> which guarantees to evaluate C<sv> only once.
+Only use this if C<sv> is an expression with side effects, otherwise use the
+more efficient C<SvPVX>.
=for apidoc Am|char*|SvPV_nomg|SV* sv|STRLEN len
Like C<SvPV> but doesn't process magic.
@@ -1569,7 +1570,8 @@ Like C<SvIV> but doesn't process magic.
=for apidoc Am|IV|SvIVx|SV* sv
Coerces the given SV to an integer and returns it. Guarantees to evaluate
-sv only once. Use the more efficient C<SvIV> otherwise.
+C<sv> only once. Only use this if C<sv> is an expression with side effects,
+otherwise use the more efficient C<SvIV>.
=for apidoc Am|NV|SvNV|SV* sv
Coerce the given SV to a double and return it. See C<SvNVx> for a version
@@ -1577,7 +1579,8 @@ which guarantees to evaluate sv only once.
=for apidoc Am|NV|SvNVx|SV* sv
Coerces the given SV to a double and returns it. Guarantees to evaluate
-sv only once. Use the more efficient C<SvNV> otherwise.
+C<sv> only once. Only use this if C<sv> is an expression with side effects,
+otherwise use the more efficient C<SvNV>.
=for apidoc Am|UV|SvUV|SV* sv
Coerces the given SV to an unsigned integer and returns it. See C<SvUVx>
@@ -1588,7 +1591,8 @@ Like C<SvUV> but doesn't process magic.
=for apidoc Am|UV|SvUVx|SV* sv
Coerces the given SV to an unsigned integer and returns it. Guarantees to
-evaluate sv only once. Use the more efficient C<SvUV> otherwise.
+C<sv> only once. Only use this if C<sv> is an expression with side effects,
+otherwise use the more efficient C<SvUV>.
=for apidoc Am|bool|SvTRUE|SV* sv
Returns a boolean indicating whether Perl would evaluate the SV as true or