mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[code] Avoid dynamic allocation and useless string copy by keeping the
importation status flag in the areaBuffer
This commit is contained in:
@@ -25,14 +25,4 @@ const char * Script::readContent() const {
|
||||
return (const char *)d.buffer+k_importationStatusSize;
|
||||
}
|
||||
|
||||
Ion::Storage::Record::ErrorStatus Script::writeContent(const char * data, size_t size) {
|
||||
// TODO: could we avoid this useless allocation?
|
||||
char * buffer = new char[size+k_importationStatusSize];
|
||||
strlcpy(buffer+1, data, size);
|
||||
buffer[0] = importationStatus() ? 1 : 0;
|
||||
ErrorStatus e = setValue({.buffer= buffer, .size = size+k_importationStatusSize});
|
||||
delete[] buffer;
|
||||
return e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user