--- a/String.st Fri Dec 23 13:41:34 2011 +0000
+++ b/String.st Fri Jan 06 08:53:28 2012 +0000
@@ -514,7 +514,6 @@
-
!String methodsFor:'Compatibility-VW5.4'!
asGUID
@@ -1104,7 +1103,7 @@
'hello world' indexOfAny:'AOE' startingAt:1
'hello world' indexOfAny:'o' startingAt:6
'hello world' indexOfAny:'o' startingAt:6
- 'hello world§' indexOfAny:'#§$' startingAt:6
+ 'hello world' indexOfAny:'#$' startingAt:6
"
!
@@ -1623,7 +1622,7 @@
^ self primitiveFailed
!
-hash
+hash_dragonBook
"return an integer useful as a hash-key"
%{ /* NOCONTEXT */
@@ -1683,6 +1682,57 @@
%}
!
+hash_sdbm
+ "return an integer useful as a hash-key"
+
+%{ /* NOCONTEXT */
+
+ REGISTER unsigned ch, val;
+ REGISTER unsigned char *cp;
+ int l;
+
+ cp = __stringVal(self);
+ l = __stringSize(self);
+ if (__qClass(self) != @global(String)) {
+ int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(self))->c_ninstvars));
+
+ cp += n;
+ l -= n;
+ }
+
+ /*
+ * this is the sdbm algorithm
+ */
+ val = 0;
+ while (l >= 4) {
+ l -= 4;
+ ch = cp[0];
+ val = (val * 65599) + ch;
+ ch = cp[1];
+ val = (val * 65599) + ch;
+ ch = cp[2];
+ val = (val * 65599) + ch;
+ ch = cp[3];
+ val = (val * 65599) + ch;
+ cp += 4;
+ }
+ while (l) {
+ l--;
+ ch = *cp++;
+ val = (val * 65599) + ch;
+ }
+ RETURN ( __mkSmallInteger(val & _MAX_INT));
+%}
+
+ "
+ 'a' hash_sdbm
+ 'ab' hash_sdbm
+ 'ab' asUnicode16String hash_sdbm
+ "
+
+ "Created: / 26-12-2011 / 13:53:09 / cg"
+!
+
~= aString
"Compare the receiver with the argument and return true if the
receiver is not equal to the argument. Otherwise return false.
@@ -3255,7 +3305,6 @@
^ super reverse
! !
-
!String methodsFor:'substring searching'!
indexOfSubCollection:aSubString startingAt:startIndex ifAbsent:exceptionValue caseSensitive:caseSensitive
@@ -3719,14 +3768,15 @@
!String class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.275 2011/01/12 13:51:12 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.276 2011/12/26 13:18:56 cg Exp $'
!
version_CVS
- ^ '§Header: /cvs/stx/stx/libbasic/String.st,v 1.275 2011/01/12 13:51:12 cg Exp §'
+ ^ 'Header: /cvs/stx/stx/libbasic/String.st,v 1.276 2011/12/26 13:18:56 cg Exp '
!
version_SVN
- ^ '$Id: String.st 10729 2011-10-31 22:19:21Z vranyj1 $'
+ ^ '$Id: String.st 10754 2012-01-06 08:53:28Z vranyj1 $'
! !
+