enum str = "abc"; vs string str = "abc";
Walter Bright
newshound2 at digitalmars.com
Wed Jan 16 23:04:07 UTC 2019
On 1/16/2019 10:21 AM, Victor Porton wrote:
> What is more space efficient:
>
> enum str = "safjkdfjksdlfkdsj";
>
> or
>
> string str = "safjkdfjksdlfkdsj";
>
> ?
You can find this out by:
dmd -c test.d
obj2asm test.obj
Also,
enum s = "hello";
size_t i = s.length;
The string "hello" does not appear in the object file.
immutable string s = "hello";
size_t i = s.length;
The string "hello" does appear in the object file.
immutable string s = "hello";
immutable string t = "hello";
The string "hello" appears only once in the object file.
More information about the Digitalmars-d
mailing list