[Issue 19896] New: [internals] Represent string and arrays as sparse literals
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 23 19:07:11 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19896
Issue ID: 19896
Summary: [internals] Represent string and arrays as sparse
literals
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ibuclaw at gdcproject.org
Given the following:
---
auto f = cast(char[2147483646]) "ab";
---
In the front-end, the initializer for this array consumes 2GB of memory
(multiplied by the number of times it is copied, I count two or three times).
StringExp {
size = 2147483646;
value = "ab\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0...";
}
When really, you could get away with only 32 bytes, if the data structure were
smarter.
StringExp {
size = 2147483646;
values [
{
index = 0;
value = 97;
},
{
index = 1;
value = 98;
}
]
}
--
More information about the Digitalmars-d-bugs
mailing list