Merge pull request #1398 from Adenilson/bigInt01

Optimize harfbuzz big integer conversions
This commit is contained in:
Behdad Esfahbod 2018-11-27 17:40:32 -05:00 committed by GitHub
commit 987f418772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -721,6 +721,12 @@ struct BEInt<Type, 2>
}
inline operator Type (void) const
{
#if defined(__GNUC__) || defined(__clang__)
/* Spoon-feed the compiler a big-endian integer with alignment 1.
* https://github.com/harfbuzz/harfbuzz/pull/1398 */
struct __attribute__((packed)) packed_uint16_t { uint16_t v; };
return __builtin_bswap16 (((packed_uint16_t *) this)->v);
#endif
return (v[0] << 8)
+ (v[1] );
}