Closed jens-mueller-sociomantic closed 5 years ago
I'm going to improve the commit message. Any more feedback?
Updated commit message and rebased.
Your commit message refers to non-array literals
, can you note the string literal case as well, since technically a string could be interpreted as an array?
Your commit message refers to
non-array literals
, can you note the string literal case as well, since technically a string could be interpreted as an array?
You mean making clearer that string literals are non-array literals? I used the term literal
for that reason. Because string
s are arrays but string literals are not array literals. But I see the potential for confusion.
Rephrase commit message and fixed indentation.
This change replaces all uses of
static immutable
withenum
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 bystatic immutable
. In all these cases D1const
served as a manifest constant. In D2enum
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 anenum
for a string literal carries no risk of allocation when used and is usually fine. Usingenum
with this in mind enables replacingstatic immutable
which is clearer in intent and avoids any possible need for static memory to hold the immutable data.