Re: getHash inconsistency

2012-03-22 Thread Sean Kelly
On Mar 22, 2012, at 11:18 AM, H. S. Teoh wrote: > On Wed, Mar 21, 2012 at 04:35:11PM +1100, Daniel Murphy wrote: >> "H. S. Teoh" wrote in message >> news:mailman.951.1332306541.4860.digitalmar...@puremagic.com... >>> >>> Here's the current hashing code for char[] and string: >>> >>> fore

Re: getHash inconsistency

2012-03-22 Thread Andrei Alexandrescu
On 3/22/12 1:18 PM, H. S. Teoh wrote: Alright, so after some benchmarking, I found that the above custom hash function works best for *short* (3 to 10 character) randomized alphabetic strings (I assumed alphabetic to be the typical use case of strings). It's faster than SuperFastHash, and even ha

Re: getHash inconsistency

2012-03-22 Thread Sean Kelly
On Mar 20, 2012, at 10:10 PM, H. S. Teoh wrote: > On Wed, Mar 21, 2012 at 03:55:49PM +1100, Daniel Murphy wrote: >> "H. S. Teoh" wrote in message >> news:mailman.917.1332250604.4860.digitalmar...@puremagic.com... > [...] >>> Then the question is, what should be the fix? >>> >>> Currently, char[

Re: getHash inconsistency

2012-03-22 Thread H. S. Teoh
On Wed, Mar 21, 2012 at 04:35:11PM +1100, Daniel Murphy wrote: > "H. S. Teoh" wrote in message > news:mailman.951.1332306541.4860.digitalmar...@puremagic.com... > > > > Here's the current hashing code for char[] and string: > > > >foreach (char c; s) > >hash = hash * 11 + c; >

Re: getHash inconsistency

2012-03-21 Thread Daniel Murphy
"H. S. Teoh" wrote in message news:mailman.951.1332306541.4860.digitalmar...@puremagic.com... > > Here's the current hashing code for char[] and string: > >foreach (char c; s) >hash = hash * 11 + c; > > For const(char)[], it's rt.util.hash.hashOf, which is Paul Hsieh's > Super

Re: getHash inconsistency

2012-03-20 Thread H. S. Teoh
On Wed, Mar 21, 2012 at 03:55:49PM +1100, Daniel Murphy wrote: > "H. S. Teoh" wrote in message > news:mailman.917.1332250604.4860.digitalmar...@puremagic.com... [...] > > Then the question is, what should be the fix? > > > > Currently, char[] and string have getHash defined in > > rt.typeinfo.ti_

Re: getHash inconsistency

2012-03-20 Thread Daniel Murphy
"H. S. Teoh" wrote in message news:mailman.917.1332250604.4860.digitalmar...@puremagic.com... > On Tue, Mar 20, 2012 at 05:07:12PM +1100, Daniel Murphy wrote: >> "H. S. Teoh" wrote in message >> news:mailman.910.1332214803.4860.digitalmar...@puremagic.com... >> > Is this a bug? >> > >> > char[]

Re: getHash inconsistency

2012-03-20 Thread H. S. Teoh
On Tue, Mar 20, 2012 at 05:07:12PM +1100, Daniel Murphy wrote: > "H. S. Teoh" wrote in message > news:mailman.910.1332214803.4860.digitalmar...@puremagic.com... > > Is this a bug? > > > > char[] a = "abc".dup; > > const(char)[] b = "abc"; > > string c = "abc"; > > > > writeln(typeid(a).getHash(&a

Re: getHash inconsistency

2012-03-19 Thread Daniel Murphy
"H. S. Teoh" wrote in message news:mailman.910.1332214803.4860.digitalmar...@puremagic.com... > Is this a bug? > > char[] a = "abc".dup; > const(char)[] b = "abc"; > string c = "abc"; > > writeln(typeid(a).getHash(&a)); // 12914 > writeln(typeid(b).getHash(&b)); // 8503969683799911018 > writeln(t

getHash inconsistency

2012-03-19 Thread H. S. Teoh
Is this a bug? char[] a = "abc".dup; const(char)[] b = "abc"; string c = "abc"; writeln(typeid(a).getHash(&a)); // 12914 writeln(typeid(b).getHash(&b)); // 8503969683799911018 writeln(typeid(c).getHash(&c)); // 12914 T -- Obviously, some things