summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2004-07-16 11:04:37 +0000
committerNicholas Clark <nick@ccl4.org>2004-07-16 11:04:37 +0000
commite90e236463307bd7f53439b91573fe42e9cb8901 (patch)
tree89bf49d9ec83486ed0205849ff8ae782b1c2947e /util.c
parentb0bc38e63ed7e7e448fb07e45ee093d3b3d54be8 (diff)
downloadperl-e90e236463307bd7f53439b91573fe42e9cb8901.tar.gz
Encourage compilers to tail call optimise in sv_savepv, sv_savepvn
and sv_savesharedpv. Need to create non-void returning versions of Copy and Zero, as the existing macros deliberately cast to (void) p4raw-id: //depot/perl@23126
Diffstat (limited to 'util.c')
-rw-r--r--util.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/util.c b/util.c
index 030c70607b..b3375de4f0 100644
--- a/util.c
+++ b/util.c
@@ -751,12 +751,12 @@ be freed with the C<Safefree()> function.
char *
Perl_savepv(pTHX_ const char *pv)
{
- register char *newaddr = Nullch;
- if (pv) {
- New(902,newaddr,strlen(pv)+1,char);
- (void)strcpy(newaddr,pv);
- }
- return newaddr;
+ register char *newaddr;
+ if (!pv)
+ return Nullch;
+
+ New(902,newaddr,strlen(pv)+1,char);
+ return strcpy(newaddr,pv);
}
/* same thing but with a known length */
@@ -780,13 +780,13 @@ Perl_savepvn(pTHX_ const char *pv, register I32 len)
New(903,newaddr,len+1,char);
/* Give a meaning to NULL pointer mainly for the use in sv_magic() */
if (pv) {
- Copy(pv,newaddr,len,char); /* might not be null terminated */
- newaddr[len] = '\0'; /* is now */
+ /* might not be null terminated */
+ newaddr[len] = '\0';
+ return CopyD(pv,newaddr,len,char);
}
else {
- Zero(newaddr,len+1,char);
+ return ZeroD(newaddr,len+1,char);
}
- return newaddr;
}
/*
@@ -800,17 +800,17 @@ which is shared between threads.
char *
Perl_savesharedpv(pTHX_ const char *pv)
{
- register char *newaddr = Nullch;
- if (pv) {
- newaddr = (char*)PerlMemShared_malloc(strlen(pv)+1);
- if (!newaddr) {
- PerlLIO_write(PerlIO_fileno(Perl_error_log),
- PL_no_mem, strlen(PL_no_mem));
- my_exit(1);
- }
- (void)strcpy(newaddr,pv);
+ register char *newaddr;
+ if (!pv)
+ return Nullch;
+
+ newaddr = (char*)PerlMemShared_malloc(strlen(pv)+1);
+ if (!newaddr) {
+ PerlLIO_write(PerlIO_fileno(Perl_error_log),
+ PL_no_mem, strlen(PL_no_mem));
+ my_exit(1);
}
- return newaddr;
+ return strcpy(newaddr,pv);
}