| 88 | } |
| 89 | |
| 90 | txStringInfo* fxCacheStringInfo(txMachine* the, txString string) |
| 91 | { |
| 92 | txStringInfoCache* cache = the->stringInfoCache; |
| 93 | txStringInfo* info = C_NULL; |
| 94 | if (cache) { |
| 95 | txInteger count = cache->count; |
| 96 | txInteger head = cache->head; |
| 97 | txInteger tail = cache->tail; |
| 98 | txInteger i; |
| 99 | i = head - 1; |
| 100 | info = cache->infos + i; |
| 101 | while (i >= 0) { |
| 102 | if (info->string == string) |
| 103 | return info; |
| 104 | i--; |
| 105 | info--; |
| 106 | } |
| 107 | i = tail - 1; |
| 108 | info = cache->infos + i; |
| 109 | while (i >= head) { |
| 110 | if (info->string == string) |
| 111 | return info; |
| 112 | i--; |
| 113 | info--; |
| 114 | } |
| 115 | if (tail < count) |
| 116 | tail++; |
| 117 | info = cache->infos + head; |
| 118 | head++; |
| 119 | if (head == count) |
| 120 | head = 0; |
| 121 | cache->head = head; |
| 122 | cache->tail = tail; |
| 123 | info->string = string; |
| 124 | info->unicodeLength = fxUnicodeLength(string, &info->utf8Length); |
| 125 | info->unicodeOffset = 0; |
| 126 | info->utf8Offset = 0; |
| 127 | info->ascii = (info->unicodeLength == info->utf8Length) ? 1 : 0; |
| 128 | } |
| 129 | return info; |
| 130 | } |
| 131 | |
| 132 | txSize fxCacheUTF8Length(txMachine* the, txString string) |
| 133 | { |
no test coverage detected