"H. S. Teoh" <hst...@quickfur.ath.cx> 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" <hst...@quickfur.ath.cx> 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(typeid(c).getHash(&c)); // 12914 >> > >> >> Of course. > [...] > > Then the question is, what should be the fix? > > Currently, char[] and string have getHash defined in > rt.typeinfo.ti_Ad.TypeInfo_Aa, which appears to be a custom hashing > algorithm, whereas const(char)[] uses TypeInfo_Array.getHash, which uses > rt.util.hash.hashOf. Which one should be used? > > > T > > -- > Life would be easier if I had the source code. -- YHL
I assume the custom hashing routine is better/faster? If so, that one. I'd assume that getHash not working the same for const strings is an oversight.