summaryrefslogtreecommitdiffstats
path: root/src/corelib/mimetypes/qmimemagicrule.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-02-03 00:18:05 +0200
committerAhmad Samir <a.samirh78@gmail.com>2023-02-07 20:04:11 +0200
commit27db859c6a36738d5074f59584ba7d2b289d1ae4 (patch)
tree4ba87eef451306062bd52d149d675eed96cfad7a /src/corelib/mimetypes/qmimemagicrule.cpp
parent498f3452285aa44580e1d03baeec126d475f8401 (diff)
Use QtMiscUtils hex/oct-related helpers
Thanks to Thiago for pointing them out in review. Change-Id: I14d588a8bd5ba29d43a5daeacfd55d974eb65557 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/mimetypes/qmimemagicrule.cpp')
-rw-r--r--src/corelib/mimetypes/qmimemagicrule.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp
index b6f2c9af20..b0846e375b 100644
--- a/src/corelib/mimetypes/qmimemagicrule.cpp
+++ b/src/corelib/mimetypes/qmimemagicrule.cpp
@@ -148,12 +148,8 @@ static inline QByteArray makePattern(const QByteArray &value)
char c = 0;
for (int i = 0; i < 2 && p + 1 < e; ++i) {
++p;
- if (*p >= '0' && *p <= '9')
- c = (c << 4) + *p - '0';
- else if (*p >= 'a' && *p <= 'f')
- c = (c << 4) + *p - 'a' + 10;
- else if (*p >= 'A' && *p <= 'F')
- c = (c << 4) + *p - 'A' + 10;
+ if (const int h = fromHex(*p); h != -1)
+ c = (c << 4) + h;
else
continue;
}