Conversation
This fixes compilation with MSVC under windows by removing the VLA from DFInstanceWindows and instead using a unique_ptr to an array on the heap.
|
as I said in the other issue, this is bad because you are doing unnecessary heap allocations in a hot path. apparently that code has always checked len > 1024, so just make the buffer 1024 bytes. |
|
@Hello71, this seems like premature optimization to me. How often is read_string used that an extra heap allocation would actually make that big of a difference? In any case, here is a compromise. We use VLAs when building under GCC, otherwise we use a fixed length of 1024 bytes. |
|
I would expect it to mainly be used when reading data from DF, maybe 10-100 times per dwarf, so the time it takes to do ~10k allocations probably isn't significant compared to the time it takes to connect to DF and read from it (i.e. I'd expect read_raw to be more of a bottleneck). On the other hand, I could be wrong about how often it's used, and you already have a pretty reasonable maximum length. |
|
I mean just use a 1024-byte buffer because of the length check right before. |
|
There's also a |
|
they've been there for over six years, so... |
|
All of the asserts there are redundant with checks just before them, so I removed them. |
This fixes compilation with MSVC under windows by removing the VLA from DFInstanceWindows and instead using a unique_ptr to an array on the heap.