diff options
author | Fredrik Lundh <fredrik@pythonware.com> | 2001-01-21 22:41:08 (GMT) |
---|---|---|
committer | Fredrik Lundh <fredrik@pythonware.com> | 2001-01-21 22:41:08 (GMT) |
commit | 7b7dd107b3654926fb75215805d6c0c8a15bf89e (patch) | |
tree | 13b2631ae40737b8f28e2466e0a64e1278564220 /Modules/ucnhash.c | |
parent | f75c9d94b4cb9f11f0ed046aa775478e559b4081 (diff) | |
download | cpython-7b7dd107b3654926fb75215805d6c0c8a15bf89e.zip cpython-7b7dd107b3654926fb75215805d6c0c8a15bf89e.tar.gz cpython-7b7dd107b3654926fb75215805d6c0c8a15bf89e.tar.bz2 |
compress unicode decomposition tables (this saves another 55k)
Diffstat (limited to 'Modules/ucnhash.c')
-rw-r--r-- | Modules/ucnhash.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Modules/ucnhash.c b/Modules/ucnhash.c index 248300e..bdcdab1 100644 --- a/Modules/ucnhash.c +++ b/Modules/ucnhash.c @@ -38,7 +38,7 @@ getname(Py_UCS4 code, char* buffer, int buflen) /* get offset into phrasebook */ offset = phrasebook_offset1[(code>>phrasebook_shift)]; - offset = phrasebook_offset2[(offset<<phrasebook_shift)+ + offset = phrasebook_offset2[(offset<<phrasebook_shift) + (code&((1<<phrasebook_shift)-1))]; if (!offset) return 0; @@ -47,13 +47,12 @@ getname(Py_UCS4 code, char* buffer, int buflen) for (;;) { /* get word index */ - if (phrasebook[offset] & 128) { - word = phrasebook[offset] & 127; - offset++; - } else { - word = (phrasebook[offset]<<8) + phrasebook[offset+1]; - offset+=2; - } + word = phrasebook[offset] - phrasebook_short; + if (word >= 0) { + word = (word << 8) + phrasebook[offset+1]; + offset += 2; + } else + word = phrasebook[offset++]; if (i) { if (i > buflen) return 0; /* buffer overflow */ |