cvsuser     04/04/11 04:36:20

  Modified:    src      string.c
  Log:
  speed up oo and other benches by a factor of eight
  
  Revision  Changes    Path
  1.184     +58 -43    parrot/src/string.c
  
  Index: string.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/string.c,v
  retrieving revision 1.183
  retrieving revision 1.184
  diff -u -w -r1.183 -r1.184
  --- string.c  10 Apr 2004 09:49:30 -0000      1.183
  +++ string.c  11 Apr 2004 11:36:20 -0000      1.184
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: string.c,v 1.183 2004/04/10 09:49:30 leo Exp $
  +$Id: string.c,v 1.184 2004/04/11 11:36:20 leo Exp $
   
   =head1 NAME
   
  @@ -672,20 +672,35 @@
                                "string_make: buffer pointer NULL, but length 
nonzero");
       }
   
  -    if (!encoding_name)
  -    {
  +    if (!encoding_name) {
  +
                internal_exception(MISSING_ENCODING_NAME,
                                "string_make: no encoding name specified");
       }
       else
       {
  -             s = new_string_header(interpreter, flags); /* FIXME: ignorning flags 
below */
  +        s = new_string_header(interpreter, flags);
   
                s->representation = enum_stringrep_unknown;
   
        if (strcmp(encoding_name, "iso-8859-1") == 0 )
        {
                        s->representation = enum_stringrep_one;
  +            /*
  +             * fast path for external (constant) strings - don't allocate
  +             * and copy data
  +             */
  +            if (flags & PObj_external_FLAG) {
  +                /* The following cast discards the 'const'.  That raises
  +                   a warning with gcc, but is ok since the caller indicated
  +                   it was safe by setting PObj_external_FLAG.
  +                   (The cast is necessary to pacify TenDRA's tcc.)
  +                   */
  +                PObj_bufstart(s) = s->strstart = const_cast(buffer);
  +                PObj_buflen(s)   = s->strlen = s->bufused = len;
  +                PObj_bufstart_external_SET(s);
  +                return s;
  +            }
       }
        else if (strcmp(encoding_name, "ucs-2") == 0 ) /* worry about endian-ness */
        {
  @@ -712,7 +727,7 @@
           s->strlen = s->bufused = 0;
       }
        }
  -     else /* even if buffer is "external", we won't use it directly */
  +        else
        {
                        string_fill_from_buffer(interpreter, buffer, len, 
encoding_name, s);
        }
  
  
  

Reply via email to