Changeset View
Changeset View
Standalone View
Standalone View
libkwineffects/kwinglplatform.cpp
Show All 18 Lines | |||||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | 20 | | |||
21 | #include "kwinglplatform.h" | 21 | #include "kwinglplatform.h" | ||
22 | // include kwinglutils_funcs.h to avoid the redeclaration issues | 22 | // include kwinglutils_funcs.h to avoid the redeclaration issues | ||
23 | // between qopengl.h and epoxy/gl.h | 23 | // between qopengl.h and epoxy/gl.h | ||
24 | #include "kwinglutils_funcs.h" | 24 | #include "kwinglutils_funcs.h" | ||
25 | #include <epoxy/gl.h> | 25 | #include <epoxy/gl.h> | ||
26 | 26 | | |||
27 | #include <QRegExp> | 27 | #include <QRegularExpression> | ||
28 | #include <QStringList> | 28 | #include <QStringList> | ||
29 | #include <QDebug> | 29 | #include <QDebug> | ||
30 | #include <QOpenGLContext> | 30 | #include <QOpenGLContext> | ||
31 | 31 | | |||
32 | #include <sys/utsname.h> | 32 | #include <sys/utsname.h> | ||
33 | 33 | | |||
34 | #include <iostream> | 34 | #include <iostream> | ||
35 | #include <iomanip> | 35 | #include <iomanip> | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 86 | { | |||
89 | 89 | | |||
90 | if (qstrcmp(name.sysname, "Linux") == 0) | 90 | if (qstrcmp(name.sysname, "Linux") == 0) | ||
91 | return parseVersionString(name.release); | 91 | return parseVersionString(name.release); | ||
92 | 92 | | |||
93 | return 0; | 93 | return 0; | ||
94 | } | 94 | } | ||
95 | 95 | | |||
96 | // Extracts the portion of a string that matches a regular expression | 96 | // Extracts the portion of a string that matches a regular expression | ||
97 | static QString extract(const QString &string, const QString &match, int offset = 0) | 97 | static QString extract(const QString &text, const QString &pattern) | ||
apol: It could make sense to return a QStringRef, we'd get to save a bunch of string allocations and… | |||||
Yes, it would be great, but could we maybe do it in another patch? QString and QStringRef have minor API differences so it's not just about replacing a few QStrings by QStringRefs. Such a change would look unrelated if you ask me. zzag: Yes, it would be great, but could we maybe do it in another patch? QString and QStringRef have… | |||||
apol: Yes, the patch is accepted, feel free to land. | |||||
98 | { | 98 | { | ||
99 | QString result; | 99 | const QRegularExpression regexp(pattern); | ||
100 | QRegExp rx(match); | 100 | const QRegularExpressionMatch match = regexp.match(text); | ||
101 | int pos = rx.indexIn(string, offset); | 101 | if (!match.hasMatch()) | ||
102 | if (pos != -1) | 102 | return QString(); | ||
103 | result = string.mid(pos, rx.matchedLength()); | 103 | return match.captured(); | ||
104 | return result; | | |||
105 | } | 104 | } | ||
106 | 105 | | |||
107 | static ChipClass detectRadeonClass(const QByteArray &chipset) | 106 | static ChipClass detectRadeonClass(const QByteArray &chipset) | ||
108 | { | 107 | { | ||
109 | if (chipset.isEmpty()) | 108 | if (chipset.isEmpty()) | ||
110 | return UnknownRadeon; | 109 | return UnknownRadeon; | ||
111 | 110 | | |||
112 | if (chipset.contains("R100") || | 111 | if (chipset.contains("R100") || | ||
▲ Show 20 Lines • Show All 1168 Lines • Show Last 20 Lines |
It could make sense to return a QStringRef, we'd get to save a bunch of string allocations and copies.