CCBMFontConfiguration::parseConfigFile is slow when .fnt file contains lots of characters. ( mine has more than 4000 characters )
I found reading .fnt file line by line slows the performance.
std::set* CCBMFontConfiguration::parseConfigFile(const char *controlFile)
{
...
// parse spacing / padding
std::string line;
std::string strLeft = contents->getCString();
while (strLeft.length() > 0)
{
int pos = strLeft.find('\n');
if (pos != (int)std::string::npos)
{
// the data is more than a line.get one line
line = strLeft.substr(0, pos);
strLeft = strLeft.substr(pos + 1);
}
else
{
// get the left data
line = strLeft;
strLeft.erase();
}
...
}
...
}
So I fixed the code like below, and fnt loading time recuded about 4sec -> 1sec.
std::set* CCBMFontConfiguration::parseConfigFile(const char *controlFile)
{
...
// parse spacing / padding
std::string line;
std::istringstream f(contents->getCString());
while (std::getline(f, line))
{
...
}
...
}