mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-11 19:35:38 -05:00
use static (And const where applicable) regular expression objects
the speed increase here is noticable since the work of creating a regex object is only done once per session
This commit is contained in:
@@ -31,9 +31,11 @@ void Map::setName(QString mapName) {
|
||||
|
||||
QString Map::mapConstantFromName(QString mapName) {
|
||||
// Transform map names of the form 'GraniteCave_B1F` into map constants like 'MAP_GRANITE_CAVE_B1F'.
|
||||
QString nameWithUnderscores = mapName.replace(QRegularExpression("([a-z])([A-Z])"), "\\1_\\2");
|
||||
static const QRegularExpression caseChange("([a-z])([A-Z])");
|
||||
QString nameWithUnderscores = mapName.replace(caseChange, "\\1_\\2");
|
||||
QString withMapAndUppercase = "MAP_" + nameWithUnderscores.toUpper();
|
||||
QString constantName = withMapAndUppercase.replace(QRegularExpression("_+"), "_");
|
||||
static const QRegularExpression underscores("_+");
|
||||
QString constantName = withMapAndUppercase.replace(underscores, "_");
|
||||
|
||||
// Handle special cases.
|
||||
// SSTidal needs to be SS_TIDAL, rather than SSTIDAL
|
||||
|
||||
Reference in New Issue
Block a user