QWindowsNativeInterface: don't allocate memory just to compare strings

Change-Id: I691d2629a78aaaee3d1741b9ab4c55b16c95bde9
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2014-08-27 12:04:21 +02:00
parent 2e3facf419
commit e311f7ac8b

View File

@ -64,7 +64,7 @@ enum ResourceType {
static int resourceType(const QByteArray &key)
{
static const QByteArray names[] = { // match ResourceType
static const char *names[] = { // match ResourceType
"renderingcontext",
"eglcontext",
"egldisplay",
@ -74,8 +74,8 @@ static int resourceType(const QByteArray &key)
"getdc",
"releasedc"
};
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key);
const char ** const end = names + sizeof(names) / sizeof(names[0]);
const char **result = std::find(names, end, key);
if (result == end)
result = std::find(names, end, key.toLower());
return int(result - names);