@@ -550,72 +550,11 @@ private class TypeInfoImpl(T) : TypeInfo
550
550
{
551
551
pragma (inline, true );
552
552
static if (is (T U == enum ))
553
- {
554
- return __typeid! U.getHash(cast (const U* ) p);
555
- }
556
- else static if (is (T == U[], U))
557
- {
558
- size_t result = 0 ;
559
- foreach (ref e; * p)
560
- result = hashOf(e, result);
561
- return result;
562
- }
563
- else static if (__traits(isIntegral, T))
564
- {
565
- static if (is (T : bool ))
566
- {
567
- return * p;
568
- }
569
- else static if (is (T == __vector (U), U))
570
- {
571
- return __typeid! U.getHash(cast (const U* ) p);
572
- }
573
- else
574
- {
575
- // Knuth's multiplicative hash with the golden ratio of 2^32 or 2^64
576
- static if (size_t .sizeof == 4 )
577
- return * p * 2_654_435_761U;
578
- else
579
- return * p * 11_400_714_819_323_198_485UL;
580
- }
581
- }
582
- else static if (__traits(isFloating, T))
583
- {
584
- import rt.util.typeinfo;
585
- return Floating! UnqualifiedType.hashOf(* p);
586
- }
587
- else static if (is (T == U* , U))
588
- {
589
- return __typeid! size_t .getHash(cast (const size_t * ) p);
590
- }
591
- else static if (is (T == U[n], U, size_t n))
592
- {
593
- const U[] t = (* p)[];
594
- return __typeid! (U[]).getHash(&t);
595
- }
596
- else static if (is (T == class ) || is (T == interface ))
597
- {
598
- return * p ? p.toHash : 0 ;
599
- }
600
- else static if (is (T == V[K], V, K))
601
- {
602
- if (! * p) return 0 ;
603
- alias F = hash_t function (scope const AA * aa, scope const TypeInfo tiRaw) nothrow pure @nogc ;
604
- auto f = cast (F) &_aaGetHash;
605
- return f (cast (AA * )p, typeid (T));
606
- }
607
- else static if (is (T == function ) || is (T == delegate ))
608
- {
609
- return hashOf (p);
610
- }
611
- else static if (is (T == void ))
612
- {
613
- return 0 ;
614
- }
553
+ return hashOf (* cast (const U* ) p);
554
+ else static if (is (T == void ) || is (T == function ))
555
+ return 0 ; // these aren't hashable
615
556
else
616
- {
617
- static assert (0 , T.stringof);
618
- }
557
+ return hashOf (* p);
619
558
}
620
559
621
560
override size_t getHash (scope const void * p) @nogc
@@ -800,7 +739,7 @@ private class TypeInfoImpl(T) : TypeInfo
800
739
else static if (is (T == U[n], U, size_t n))
801
740
{
802
741
private alias NextType = U;
803
- private enum uint uint _flags = __typeid! U._flags;
742
+ private enum uint _flags = __typeid! U._flags;
804
743
}
805
744
else static if (is (T == V[K], K, V))
806
745
{
@@ -876,12 +815,8 @@ unittest
876
815
static if (is (T : int ) && T.sizeof == 4 )
877
816
{
878
817
int a = 42 , b = 42 , c = 43 ;
879
- static if (size_t .sizeof == 4 )
880
- enum size_t h = 4112119562 ;
881
- else
882
- enum size_t h = 17661420568835545970UL ;
883
- assert (id.getHash(&a) == h);
884
- assert (id2.getHash(&a) == h);
818
+ assert (id.getHash(&a) == a);
819
+ assert (id2.getHash(&a) == a);
885
820
assert (id.equals(&a, &b));
886
821
assert (id2.equals(&a, &b));
887
822
assert (! id.equals(&a, &c));
0 commit comments