Mercurial > cpython-lru_cache-weakref
diff Modules/_struct.c @ 38322:c77da2736fb2 legacy-trunk
fix test_float regression and 64-bit size mismatch issue
| author | Bob Ippolito <bob@redivi.com> |
|---|---|
| date | Thu, 25 May 2006 21:09:45 +0000 |
| parents | 68a348c9868d |
| children | 36cd4a4ab8f7 |
line wrap: on
line diff
--- a/Modules/_struct.c Thu May 25 20:52:38 2006 +0000 +++ b/Modules/_struct.c Thu May 25 21:09:45 2006 +0000 @@ -1486,14 +1486,28 @@ other = lilendian_table; else other = bigendian_table; + /* Scan through the native table, find a matching + entry in the endian table and swap in the + native implementations whenever possible + (64-bit platforms may not have "standard" sizes) */ while (native->format != '\0' && other->format != '\0') { ptr = other; while (ptr->format != '\0') { if (ptr->format == native->format) { + /* Match faster when formats are + listed in the same order */ + if (ptr == other) + other++; + /* Only use the trick if the + size matches */ + if (ptr->size != native->size) + break; + /* Skip float and double, could be + "unknown" float format */ + if (ptr->format == 'd' || ptr->format == 'f') + break; ptr->pack = native->pack; ptr->unpack = native->unpack; - if (ptr == other) - other++; break; } ptr++;
