forked from qt-creator/qt-creator
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:
@@ -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
|
||||
|
22
src/plugins/qmldesigner/utils/designeralgorithm.h
Normal file
22
src/plugins/qmldesigner/utils/designeralgorithm.h
Normal 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
|
Reference in New Issue
Block a user