HD Packs: Optimized some bottlenecks when parsing definition file
This commit is contained in:
parent
8b31493fda
commit
64ae52322a
3 changed files with 17 additions and 11 deletions
|
@ -349,12 +349,11 @@ void HdPackLoader::ProcessTileTag(vector<string> &tokens, vector<HdPackCondition
|
|||
HdPackBitmapInfo &bitmapInfo = _hdNesBitmaps[tileInfo->BitmapIndex];
|
||||
uint32_t bitmapOffset = tileInfo->Y * bitmapInfo.Width + tileInfo->X;
|
||||
uint32_t* pngData = (uint32_t*)bitmapInfo.PixelData.data();
|
||||
|
||||
tileInfo->HdTileData.resize(64 * _data->Scale * _data->Scale);
|
||||
for(uint32_t y = 0; y < 8 * _data->Scale; y++) {
|
||||
for(uint32_t x = 0; x < 8 * _data->Scale; x++) {
|
||||
tileInfo->HdTileData.push_back(pngData[bitmapOffset]);
|
||||
bitmapOffset++;
|
||||
}
|
||||
bitmapOffset += bitmapInfo.Width - 8 * _data->Scale;
|
||||
memcpy(tileInfo->HdTileData.data() + (y * 8 * _data->Scale), pngData + bitmapOffset, 8 * _data->Scale * sizeof(uint32_t));
|
||||
bitmapOffset += bitmapInfo.Width;
|
||||
}
|
||||
|
||||
tileInfo->UpdateFlags();
|
||||
|
|
|
@ -191,7 +191,12 @@ string FolderUtilities::GetFolderName(string filepath)
|
|||
|
||||
string FolderUtilities::CombinePath(string folder, string filename)
|
||||
{
|
||||
return (fs::u8path(folder) / fs::u8path(filename)).u8string();
|
||||
//Windows supports forward slashes for paths, too. And fs::u8path is abnormally slow.
|
||||
if(folder[folder.length() - 1] != '/') {
|
||||
return folder + "/" + filename;
|
||||
} else {
|
||||
return folder + filename;
|
||||
}
|
||||
}
|
||||
|
||||
int64_t FolderUtilities::GetFileModificationTime(string filepath)
|
||||
|
|
|
@ -7,12 +7,14 @@ public:
|
|||
static vector<string> Split(string input, char delimiter)
|
||||
{
|
||||
vector<string> result;
|
||||
size_t index;
|
||||
while((index = input.find(delimiter)) != string::npos) {
|
||||
result.push_back(input.substr(0, index));
|
||||
input = input.substr(index + 1, input.size() - index - 1);
|
||||
size_t index = 0;
|
||||
size_t lastIndex = 0;
|
||||
while((index = input.find(delimiter, index)) != string::npos) {
|
||||
result.push_back(input.substr(lastIndex, index - lastIndex));
|
||||
index++;
|
||||
lastIndex = index;
|
||||
}
|
||||
result.push_back(input);
|
||||
result.push_back(input.substr(lastIndex));
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue