diff options
author | Grigori Goronzy <greg@kinoho.net> | 2014-01-29 12:13:09 -0800 |
---|---|---|
committer | Grigori Goronzy <greg@kinoho.net> | 2014-01-29 12:13:09 -0800 |
commit | 678a46dfc18ccadedf79a6da8104a84d2bd9dbf7 (patch) | |
tree | ea9be63bf000e0b83f6cef6ce366eec89e48c08f | |
parent | 0d158946f61060e1032657b196e47d461ef44b52 (diff) | |
parent | f466b9678b4b68e56d7374dea51218348d628b06 (diff) | |
download | libass-678a46dfc18ccadedf79a6da8104a84d2bd9dbf7.tar.bz2 libass-678a46dfc18ccadedf79a6da8104a84d2bd9dbf7.tar.xz |
Merge pull request #39 from grigorig/shaper-hash-opt
Shaper and hash function optimizations
-rw-r--r-- | libass/ass_shaper.c | 10 | ||||
-rw-r--r-- | libass/ass_utils.h | 13 |
2 files changed, 14 insertions, 9 deletions
diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c index 0e81824..8f12291 100644 --- a/libass/ass_shaper.c +++ b/libass/ass_shaper.c @@ -140,15 +140,15 @@ static void init_features(ASS_Shaper *shaper) shaper->n_features = NUM_FEATURES; shaper->features[VERT].tag = HB_TAG('v', 'e', 'r', 't'); - shaper->features[VERT].end = INT_MAX; + shaper->features[VERT].end = UINT_MAX; shaper->features[VKNA].tag = HB_TAG('v', 'k', 'n', 'a'); - shaper->features[VKNA].end = INT_MAX; + shaper->features[VKNA].end = UINT_MAX; shaper->features[KERN].tag = HB_TAG('k', 'e', 'r', 'n'); - shaper->features[KERN].end = INT_MAX; + shaper->features[KERN].end = UINT_MAX; shaper->features[LIGA].tag = HB_TAG('l', 'i', 'g', 'a'); - shaper->features[LIGA].end = INT_MAX; + shaper->features[LIGA].end = UINT_MAX; shaper->features[CLIG].tag = HB_TAG('c', 'l', 'i', 'g'); - shaper->features[CLIG].end = INT_MAX; + shaper->features[CLIG].end = UINT_MAX; } /** diff --git a/libass/ass_utils.h b/libass/ass_utils.h index 6d795f0..4e2ba6c 100644 --- a/libass/ass_utils.h +++ b/libass/ass_utils.h @@ -132,11 +132,16 @@ static inline int rot_key(double a) static inline unsigned fnv_32a_buf(void *buf, size_t len, unsigned hval) { unsigned char *bp = buf; - unsigned char *be = bp + len; - while (bp < be) { - hval ^= (unsigned) *bp++; - hval *= FNV1_32A_PRIME; + size_t n = (len + 3) / 4; + + switch (len % 4) { + case 0: do { hval ^= (unsigned) *bp++; hval *= FNV1_32A_PRIME; + case 3: hval ^= (unsigned) *bp++; hval *= FNV1_32A_PRIME; + case 2: hval ^= (unsigned) *bp++; hval *= FNV1_32A_PRIME; + case 1: hval ^= (unsigned) *bp++; hval *= FNV1_32A_PRIME; + } while (--n > 0); } + return hval; } static inline unsigned fnv_32a_str(char *str, unsigned hval) |