Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change replaces all uses of `static immutable` with `enum` where the use of manifest constant won't cause an allocation. Specifically, this is the case when defining manifest constants using non-array literals (which includes string literals). When converting to D2-only (see 6b81096) D1 `const` was replaced by `static immutable`. In all these cases D1 `const` served as a manifest constant. In D2 `enum` is used to define manifest constants. This is preferred except when done for array literals accessed more than once when running. Because in this case each use of the manifest constant will cause an allocation which is often not wanted. This does not apply to string literals which are treated specially. Hence, using an `enum` for a string literal carries no risk of allocation when used and is usually fine. Using `enum` with this in mind enables replacing `static immutable` which is clearer in intent and avoids any possible need for static memory to hold the immutable data.
- Loading branch information