class Prism::CodeUnitsCache

Parent:
Object

A cache that can be used to quickly compute code unit offsets from byte offsets. It purposefully provides only a single [] method to access the cache in order to minimize surface area.

Note that there are some known issues here that may or may not be addressed in the future:

  • The first is that there are issues when the cache computes values that are not on character boundaries. This can result in subsequent computations being off by one or more code units.

  • The second is that this cache is currently unbounded. In theory we could introduce some kind of LRU cache to limit the number of entries, but this has not yet been implemented.

Ruby Core © 1993–2024 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.