Rework SymbolTableCache::str2sym member #938
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So far our symbol name to symbol index inside the SymbolTableCache type was just referencing memory mapped strings directly. That works well, but it breaks once we introduce the option of not using a memory mapping but reading sections from a file using "regular" file I/O -- which is something that we require as a "fallback" with upcoming changes. Basically, if SymbolTableCache::strs is heap allocated then str2sym can't easily reference data from it, as that would be self-referential. To work around this issue, instead of storing references inside the str2sym table, we work with indexes.
As a perhaps positive side effect of making this change, we also opted for pushing the string validation further out to the point where we actually need the Unicode string. This could, conceivably, help in cases where, say, a symbol table contains corrupt or otherwise garbled symbol names.