/[guile]/guile/guile-core/libguile/hash.c
ViewVC logotype

Diff of /guile/guile-core/libguile/hash.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.50 by dirk, Thu Sep 18 20:55:40 2003 UTC revision 1.51 by mvo, Mon Nov 17 16:56:48 2003 UTC
# Line 1  Line 1 
1  /*      Copyright (C) 1995,1996,1997, 2000, 2001 Free Software Foundation, Inc.  /*      Copyright (C) 1995,1996,1997, 2000, 2001, 2003 Free Software Foundation, Inc.
2   *   *
3   * This library is free software; you can redistribute it and/or   * This library is free software; you can redistribute it and/or
4   * modify it under the terms of the GNU Lesser General Public   * modify it under the terms of the GNU Lesser General Public
# Line 37  extern double floor(); Line 37  extern double floor();
37  unsigned long  unsigned long
38  scm_string_hash (const unsigned char *str, size_t len)  scm_string_hash (const unsigned char *str, size_t len)
39  {  {
40    if (len > 5)    /* from suggestion at: */
41      {    /* http://srfi.schemers.org/srfi-13/mail-archive/msg00112.html */
42        size_t i = 5;  
43        unsigned long h = 264;    unsigned long h = 0;
44        while (i--)    while (len-- > 0)
45          h = (h << 8) + (unsigned) str[h % len];      h = *str++ + h*37;
46        return h;    return h;
     }  
   else  
     {  
       size_t i = len;  
       unsigned long h = 0;  
       while (i)  
         h = (h << 8) + (unsigned) str[--i];  
       return h;  
     }  
47  }  }
48    
49    

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26