Details
-
Suggestion
-
Resolution: Unresolved
-
P4: Low
-
None
-
None
Description
While working on the AST node for property and attributes, and observing the way we work with FileLocationRegions, where there is a repetition of multiple enum-s, which are essentially a "subset" of Tokens..
soo high level idea is to have a generic class, where mapped container storing SourceLocations can be either flatmap (more useful for FileLocations::Info) OR array (where the size is small and known beforehand, like AST::Nodes)
which can be constructed based on the set of tokens
let's say {T_DEFAULT, T_FINAL, T_READONLY} , where each of the tokens have different values will be mapped to the array indices.
In case with map it's pretty simple it's just flatmap<TOKEN, SourceLocation> However with the array, where it would be nice to have accesss like arr[T_DEFAULT] and arr[T_READONLY] this is more complicated and requires more attentive boundary checking. However such container might potentially be used in many places
So the first step will anyway be gathering some data and trying to figure out how beneficial this could be