mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
#Use Data::takeBuffer replace deep copy data.
Avoid unnecessary memory alloc & copy
This commit is contained in:
parent
e23bec8ddb
commit
4f3a82834c
@ -75,11 +75,8 @@ void _spAtlasPage_disposeTexture (spAtlasPage* self) {
|
||||
}
|
||||
|
||||
char* _spUtil_readFile (const char* path, int* length) {
|
||||
Data data = FileUtils::getInstance()->getDataFromFile(
|
||||
FileUtils::getInstance()->fullPathForFilename(path).c_str());
|
||||
Data data = FileUtils::getInstance()->getDataFromFile(
|
||||
FileUtils::getInstance()->fullPathForFilename(path));
|
||||
if (data.isNull()) return 0;
|
||||
*length = static_cast<int>(data.getSize());
|
||||
char* bytes = MALLOC(char, *length);
|
||||
memcpy(bytes, data.getBytes(), *length);
|
||||
return bytes;
|
||||
return (char*)(data.takeBuffer((ssize_t*)length));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user