cvsuser     04/04/16 23:22:56

  Modified:    src      hash.c objects.c string.c
  Log:
  [perl #28868] [PATCH] signedness tweak for string.c:
  The attached patch lazily changes both offs and d to unsigned, which
  seems to fine by the Tru64 cc.
  
  Courtesy of Jarkko Hietaniemi <[EMAIL PROTECTED]>
  
  * Plus some changes WRT precomputed hash values.
  * Object comments
  
  Revision  Changes    Path
  1.79      +11 -2     parrot/src/hash.c
  
  Index: hash.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/hash.c,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -w -r1.78 -r1.79
  --- hash.c    16 Apr 2004 12:49:55 -0000      1.78
  +++ hash.c    17 Apr 2004 06:22:55 -0000      1.79
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: hash.c,v 1.78 2004/04/16 12:49:55 leo Exp $
  +$Id: hash.c,v 1.79 2004/04/17 06:22:55 leo Exp $
   
   =head1 NAME
   
  @@ -146,10 +146,19 @@
   
   */
   
  +/* see also string.c */
  +#define  USE_HASH_VAL 1
  +
   static size_t
   key_hash_STRING(Interp *interpreter, Hash *hash, void *value)
   {
  -     return string_hash(interpreter, hash, (STRING *)value);
  +    STRING *s = value;
  +#if USE_HASH_VAL
  +    if (PObj_constant_TEST(s) && s->hashval) {
  +        return s->hashval ^ hash->seed;
  +    }
  +#endif
  +    return string_hash(interpreter, hash, s);
   }
   
   /*
  
  
  
  1.85      +9 -3      parrot/src/objects.c
  
  Index: objects.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/objects.c,v
  retrieving revision 1.84
  retrieving revision 1.85
  diff -u -w -r1.84 -r1.85
  --- objects.c 16 Apr 2004 12:49:56 -0000      1.84
  +++ objects.c 17 Apr 2004 06:22:56 -0000      1.85
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: objects.c,v 1.84 2004/04/16 12:49:56 leo Exp $
  +$Id: objects.c,v 1.85 2004/04/17 06:22:56 leo Exp $
   
   =head1 NAME
   
  @@ -36,6 +36,8 @@
       count = VTABLE_elements(interpreter, source_array);
       /*
        * preserve type, we have OrderedHash and Array
  +     * XXX this doesn't preserve the keys of the ordered hash
  +     *     (but the keys aren't used -leo)
        */
       new_array = pmc_new(interpreter, source_array->vtable->base_type);
       VTABLE_set_integer_native(interpreter, new_array, count);
  @@ -465,7 +467,7 @@
   
   static PMC*
   get_init_meth(Parrot_Interp interpreter, PMC *class,
  -         STRING *prop_str , STRING **meth_str)
  +         const STRING *prop_str , STRING **meth_str)
   {
       PMC *prop;
       STRING *meth;
  @@ -515,6 +517,10 @@
           /*
            * 1) if class has a CONSTRUCT property run it on the object
            *    no redispatch
  +         *
  +         *  TODO if the first meth is found, save registers, do all init
  +         *       calls and after the last one restore registers.
  +         *
            */
           STRING *meth_str;
           PMC *meth = get_init_meth(interpreter, class, _S("CONSTRUCT"),
  
  
  
  1.193     +25 -8     parrot/src/string.c
  
  Index: string.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/string.c,v
  retrieving revision 1.192
  retrieving revision 1.193
  diff -u -w -r1.192 -r1.193
  --- string.c  16 Apr 2004 12:47:56 -0000      1.192
  +++ string.c  17 Apr 2004 06:22:56 -0000      1.193
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: string.c,v 1.192 2004/04/16 12:47:56 leo Exp $
  +$Id: string.c,v 1.193 2004/04/17 06:22:56 leo Exp $
   
   =head1 NAME
   
  @@ -27,6 +27,8 @@
   #include "parrot/parrot.h"
   #include <assert.h>
   
  +#define USE_HASH_VAL 1
  +
   /*
    * this extra size is in the hope, that some concat ops might
    * follow in a sequence.
  @@ -733,6 +735,13 @@
                   PObj_bufstart(s) = s->strstart = const_cast(buffer);
                   PObj_buflen(s)   = s->strlen = s->bufused = len;
                   PObj_bufstart_external_SET(s);
  +#if USE_HASH_VAL
  +                if (flags & PObj_constant_FLAG) {
  +                    Hash hash;
  +                    hash.seed = 0;
  +                    s->hashval = string_hash(interpreter, &hash, s);
  +                }
  +#endif
                   return s;
               }
           }
  @@ -757,6 +766,13 @@
               else {
                   s->strlen = s->bufused = 0;
               }
  +#if USE_HASH_VAL
  +                if (flags & PObj_constant_FLAG) {
  +                    Hash hash;
  +                    hash.seed = 0;
  +                    s->hashval = string_hash(interpreter, &hash, s);
  +                }
  +#endif
           }
           else {
               string_fill_from_buffer(interpreter, buffer, len, encoding_name, s);
  @@ -2813,7 +2829,6 @@
   
   */
   
  -#define USE_HASH_VAL 0
   size_t
   string_hash(struct Parrot_Interp * interpreter, Hash *hash, STRING *s)
   {
  @@ -2827,11 +2842,6 @@
   
       if (!s)
           return 0;
  -#if USE_HASH_VAL
  -    if (PObj_constant_TEST(s) && s->hashval) {
  -        return s->hashval ^ hash->seed;
  -    }
  -#endif
   
       switch (s->representation) {
           case enum_stringrep_one:
  @@ -2956,7 +2966,7 @@
   {
       size_t clength = strlen(cstring);
       STRING *result;
  -    int offs, d;
  +    unsigned int offs, d;
       Parrot_UInt4 r;
       Parrot_unescape_cb char_at;
       char_setter_func set_char_at;
  @@ -3007,6 +3017,13 @@
       }
       result->strlen = d;
       result->bufused = string_max_bytes(interpreter, result, d);
  +#if USE_HASH_VAL
  +    {
  +        Hash hash;
  +        hash.seed = 0;
  +        result->hashval = string_hash(interpreter, &hash, result);
  +    }
  +#endif
       return result;
   }
   
  
  
  

Reply via email to