QmlDesigner: Add contains functions

After extensive
benchmarking(https://quick-bench.com/q/ajHEd5ZE-zmI2FoLQLGX9NREgmw)
there was a clear result that a forced inline variatic function provides
the fastest result.

static bool search(QByteArrayView input)
{
    return CoreUtils::contains(input,
                               "children",
                               "data",
                               "childrenRect",
                               "icon",
                               "left",
                               "transform",
                               "visibleChildren");
}

Change-Id: Id492bb4351bf3e87fc8e85c2b99e8d2a9b3efd0d
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Marco Bubke
2023-08-03 09:29:52 +02:00
parent 787f17ce91
commit 6f5e9417d8
2 changed files with 23 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ add_qtc_library(QmlDesignerUtils STATIC
SOURCES_PREFIX ${CMAKE_CURRENT_LIST_DIR}/utils
SOURCES
asset.cpp asset.h
designeralgorithm.h
filedownloader.cpp filedownloader.h
multifiledownloader.cpp multifiledownloader.h
fileextractor.cpp fileextractor.h

View File

@@ -0,0 +1,22 @@
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <QtGlobal>
namespace QmlDesigner::CoreUtils {
template<typename Element, typename... Elements>
#ifdef Q_CC_MSVC
__forceinline
#else
[[gnu::always_inline]]
#endif
constexpr bool
contains(Element element, Elements... elements)
{
return ((element == elements) || ...);
}
} // namespace QmlDesigner::CoreUtils