Source File
caches.go
Belonging Package
github.com/go-text/typesetting/harfbuzz
package harfbuzz// Code generated by typesetting-utils/generators/cache/gen.go. DO NOT EDIT./* Implements caches for integers key->value functions.** The cache is a fixed-size array of 8-bit, 16-bit or 32-bit integers,* typically 256 elements.** The key is split into two parts: the cache index (high bits)* and the rest (low bits).** The memory layout is the following :* KEY = <key bits - cache bits><cache bits>* VALUE = <key bits - cache bits><value bits>* with the constraints* KEY in [0, 2^key bits[* VALUE in [0, 2^value bits[** The cache index is used to index into the array. The array* member is an integer that is used BOTH* to store the low bits of the key, and the value.** The value is stored in the least significant bits of the integer.* The low bits of the key are stored in the most significant bits* of the integer.** A cache hit is detected by comparing the low bits of the key* with the high bits of the integer at the array position indexed* by the high bits of the key. If they match, the value is extracted* from the least significant bits of the integer and returned.* Otherwise, a cache miss is reported.** Cache operations (storage and retrieval) involve just a few* arithmetic operations and a single memory access.*/// cache15_8_7 is a cache for integer (key, value) pairs,// with 0 <= key < 32768 and 0 <= value < 256type cache15_8_7 [1 << 7]uint16// clear should be used as init functionfunc ( *cache15_8_7) () {for := range {[] = ^uint16(0)}}func ( cache15_8_7) ( uint16) (uint16, bool) {:= & ((1 << 7) - 1):= []if == ^uint16(0) || (>>8) != uint16(>>7) {return 0, false}return & ((1 << 8) - 1), true}func ( *cache15_8_7) ( uint16, uint16) {if (>>15) != 0 || (>>8) != 0 { /* overflows */return}.setUnchecked(, )}// assumes key < 32768 and value < 256func ( *cache15_8_7) ( uint16, uint16) {:= & ((1 << 7) - 1):= (uint16(>>7) << 8) |[] =}// cache21_3_8 is a cache for integer (key, value) pairs,// with 0 <= key < 2097152 and 0 <= value < 8type cache21_3_8 [1 << 8]uint16// clear should be used as init functionfunc ( *cache21_3_8) () {for := range {[] = ^uint16(0)}}func ( cache21_3_8) ( uint32) (uint16, bool) {:= & ((1 << 8) - 1):= []if == ^uint16(0) || (>>3) != uint16(>>8) {return 0, false}return & ((1 << 3) - 1), true}func ( *cache21_3_8) ( uint32, uint16) {if (>>21) != 0 || (>>3) != 0 { /* overflows */return}.setUnchecked(, )}// assumes key < 2097152 and value < 8func ( *cache21_3_8) ( uint32, uint16) {:= & ((1 << 8) - 1):= (uint16(>>8) << 3) |[] =}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |