[Scummvm-git-logs] scummvm master -> 42b4e7ca10de9d6efb843c58e47a41ff93f6c386
lephilousophe
noreply at scummvm.org
Thu Aug 7 18:52:14 UTC 2025
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
0d549d86f9 DETECTION: Don't call appendComponent when it's not needed
58362a6ada COMMON: Improve punyencode performance
42b4e7ca10 COMMON: Improve scumm_stricmp and scumm_strnicmp performance
Commit: 0d549d86f91c72fd22bb9328d2691937d9289097
https://github.com/scummvm/scummvm/commit/0d549d86f91c72fd22bb9328d2691937d9289097
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-08-07T19:50:21+02:00
Commit Message:
DETECTION: Don't call appendComponent when it's not needed
Changed paths:
engines/advancedDetector.cpp
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index cc6072d5ece..dd5f410c5d7 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -442,7 +442,7 @@ void AdvancedMetaEngineDetectionBase::composeFileHashMap(FileMap &allFiles, cons
for (const auto &file : fslist) {
Common::String efname = Common::punycode_encodefilename(file.getName());
- Common::Path tstr = ((_flags & kADFlagMatchFullPaths) ? parentName : Common::Path()).appendComponent(efname);
+ Common::Path tstr = (_flags & kADFlagMatchFullPaths) ? parentName.appendComponent(efname) : Common::Path(efname, Common::Path::kNoSeparator);
if (file.isDirectory()) {
if (!_globsMap.contains(efname))
@@ -459,7 +459,7 @@ void AdvancedMetaEngineDetectionBase::composeFileHashMap(FileMap &allFiles, cons
// Strip any trailing dot
if (efname.lastChar() == '.') {
efname.deleteLastChar();
- tstr = ((_flags & kADFlagMatchFullPaths) ? parentName : Common::Path()).appendComponent(efname);
+ tstr = (_flags & kADFlagMatchFullPaths) ? parentName.appendComponent(efname) : Common::Path(efname, Common::Path::kNoSeparator);
}
debugC(9, kDebugGlobalDetection, "$$ ['%s'] ['%s'] in '%s", tstr.toString().c_str(), efname.c_str(), firstPathComponents(fslist.front().getPath().toString(), '/').c_str());
Commit: 58362a6ada8bb75a554d4f49cfd47243dcf10a2b
https://github.com/scummvm/scummvm/commit/58362a6ada8bb75a554d4f49cfd47243dcf10a2b
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-08-07T20:04:24+02:00
Commit Message:
COMMON: Improve punyencode performance
When dealing with empty or ASCII strings, don't call UTF-8 conversion
routines as it's not needed.
Decrease the number of append calls.
Changed paths:
common/punycode.cpp
diff --git a/common/punycode.cpp b/common/punycode.cpp
index 9b32ec57c8a..bf54e51d254 100644
--- a/common/punycode.cpp
+++ b/common/punycode.cpp
@@ -133,7 +133,7 @@ String punycode_encode(const U32String &src) {
String dst = "xn--";
if (!srclen)
- return src;
+ return String();
for (si = 0; si < srclen; si++) {
if (src[si] < 128) {
@@ -155,8 +155,8 @@ String punycode_encode(const U32String &src) {
src[2] == '-' && src[3] == '-')
return dst + '-';
-
- return src;
+ // We already did the job converting to ASCII, don't do it again
+ return dst.substr(4);
}
// If we have any ASCII characters, add '-' to separate them from
@@ -377,15 +377,16 @@ String punycode_encodefilename(const U32String &src) {
U32String dst;
for (uint i = 0; i < src.size(); i++) {
- if (src[i] == 0x81) { // In case we have our escape character present
- dst += 0x81;
- dst += 0x79;
+ U32String::value_type c = src[i];
+ if (c == 0x81) { // In case we have our escape character present
+ const U32String::value_type tmp[] = { 0x81, 0x79 };
+ dst.append(tmp, tmp + 2);
// Encode special symbols and non-printables
- } else if ((src[i] < 0x80 && strchr(SPECIAL_SYMBOLS, (byte)src[i])) || src[i] < 0x20) {
- dst += 0x81;
- dst += src[i] + 0x80;
+ } else if (c < 0x20 || (c < 0x80 && strchr(SPECIAL_SYMBOLS, (byte)c))) {
+ const U32String::value_type tmp[] = { 0x81, c + 0x80 };
+ dst.append(tmp, tmp + 2);
} else {
- dst += src[i];
+ dst.append(1, c);
}
}
Commit: 42b4e7ca10de9d6efb843c58e47a41ff93f6c386
https://github.com/scummvm/scummvm/commit/42b4e7ca10de9d6efb843c58e47a41ff93f6c386
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2025-08-07T20:19:28+02:00
Commit Message:
COMMON: Improve scumm_stricmp and scumm_strnicmp performance
Avoid calling tolower when the characters are equal.
Changed paths:
common/str.cpp
diff --git a/common/str.cpp b/common/str.cpp
index da1b44a9d9e..c63429a3122 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -840,33 +840,37 @@ String percentEncodeString(const String &src) {
// TODO: Rename this to Common::strcasecmp
int scumm_stricmp(const char *s1, const char *s2) {
byte l1, l2;
+ int result;
do {
- // Don't use ++ inside tolower, in case the macro uses its
- // arguments more than once.
l1 = (byte)*s1++;
- l1 = tolower(l1);
l2 = (byte)*s2++;
- l2 = tolower(l2);
- } while (l1 == l2 && l1 != 0);
- return l1 - l2;
+
+ result = l1 - l2;
+ if (result) {
+ result = tolower(l1) - tolower(l2);
+ }
+ } while (!result && l1 != 0);
+ return result;
}
// Portable implementation of strnicmp / strncasecmp / strncmpi.
// TODO: Rename this to Common::strncasecmp
int scumm_strnicmp(const char *s1, const char *s2, uint n) {
byte l1, l2;
+ int result;
do {
if (n-- == 0)
return 0; // no difference found so far -> signal equality
- // Don't use ++ inside tolower, in case the macro uses its
- // arguments more than once.
l1 = (byte)*s1++;
- l1 = tolower(l1);
l2 = (byte)*s2++;
- l2 = tolower(l2);
- } while (l1 == l2 && l1 != 0);
- return l1 - l2;
+
+ result = l1 - l2;
+ if (result) {
+ result = tolower(l1) - tolower(l2);
+ }
+ } while (!result && l1 != 0);
+ return result;
}
const char *scumm_skipArticle(const char *s1) {
More information about the Scummvm-git-logs
mailing list