comparison lphobos/internal/adi.d @ 473:373489eeaf90

Applied downs' lphobos update
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 04 Aug 2008 19:28:49 +0200
parents 5ab8e92611f9
children 88e23f8c2354
comparison
equal deleted inserted replaced
472:15c804b6ce77 473:373489eeaf90
36 import std.c.string; 36 import std.c.string;
37 //import std.string; 37 //import std.string;
38 import std.outofmemory; 38 import std.outofmemory;
39 import std.utf; 39 import std.utf;
40 40
41 pragma(LLVM_internal, "notypeinfo") 41 pragma(no_typeinfo)
42 struct Array 42 struct Array
43 { 43 {
44 size_t length; 44 size_t length;
45 void* ptr; 45 void* ptr;
46 } 46 }
460 * Support for array equality test. 460 * Support for array equality test.
461 */ 461 */
462 462
463 extern (C) int _adEq(Array a1, Array a2, TypeInfo ti) 463 extern (C) int _adEq(Array a1, Array a2, TypeInfo ti)
464 { 464 {
465 //printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length); 465 // printf("_adEq(a1.length = %d, a2.length = %d)\n", a1.length, a2.length);
466 if (a1.length != a2.length) 466 if (a1.length != a2.length)
467 return 0; // not equal 467 return 0; // not equal
468 auto sz = ti.tsize(); 468 auto sz = ti.next.tsize();
469 auto p1 = a1.ptr; 469 auto p1 = a1.ptr;
470 auto p2 = a2.ptr; 470 auto p2 = a2.ptr;
471 471
472 /+ 472 /+
473 for (int i = 0; i < a1.length; i++) 473 for (int i = 0; i < a1.length; i++)
474 { 474 {
475 printf("%4x %4x\n", (cast(short*)p1)[i], (cast(short*)p2)[i]); 475 printf("%4x %4x\n", (cast(short*)p1)[i], (cast(short*)p2)[i]);
476 } 476 }
478 +/ 478 +/
479 479
480 if (sz == 1) 480 if (sz == 1)
481 // We should really have a ti.isPOD() check for this 481 // We should really have a ti.isPOD() check for this
482 return (memcmp(p1, p2, a1.length) == 0); 482 return (memcmp(p1, p2, a1.length) == 0);
483 483
484 for (size_t i = 0; i < a1.length; i++) 484 for (size_t i = 0; i < a1.length; i++)
485 { 485 {
486 if (!ti.equals(p1 + i * sz, p2 + i * sz)) 486 if (!ti.next.equals(p1 + i * sz, p2 + i * sz))
487 return 0; // not equal 487 return 0; // not equal
488 } 488 }
489 return 1; // equal 489 return 1; // equal
490 } 490 }
491 491