Simplify a static array iteration

Change-Id: I7dc4fdcbbaef08c1bc3b23403cd13e2c23585f75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131733
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2022-03-18 12:27:57 +03:00
parent fbb41798b8
commit 21b17ba1e6

View File

@@ -17,6 +17,7 @@
#include <set> #include <set>
#include <stack> #include <stack>
#include <string_view> #include <string_view>
#include <utility>
#include <vector> #include <vector>
#include <com/sun/star/container/NoSuchElementException.hpp> #include <com/sun/star/container/NoSuchElementException.hpp>
@@ -1831,33 +1832,27 @@ cppuhelper::TypeManager::TypeManager():
css::uno::Any cppuhelper::TypeManager::find(OUString const & name) { css::uno::Any cppuhelper::TypeManager::find(OUString const & name) {
//TODO: caching? (here or in unoidl::Manager?) //TODO: caching? (here or in unoidl::Manager?)
struct Simple { static constexpr std::pair<std::u16string_view, css::uno::TypeClass> const simple[] = {
std::u16string_view name; { u"void", css::uno::TypeClass_VOID },
css::uno::TypeClass typeClass; { u"boolean", css::uno::TypeClass_BOOLEAN },
}; { u"byte", css::uno::TypeClass_BYTE },
static Simple const simple[] = { { u"short", css::uno::TypeClass_SHORT },
{ std::u16string_view(u"void"), css::uno::TypeClass_VOID }, { u"unsigned short", css::uno::TypeClass_UNSIGNED_SHORT },
{ std::u16string_view(u"boolean"), css::uno::TypeClass_BOOLEAN }, { u"long", css::uno::TypeClass_LONG },
{ std::u16string_view(u"byte"), css::uno::TypeClass_BYTE }, { u"unsigned long", css::uno::TypeClass_UNSIGNED_LONG },
{ std::u16string_view(u"short"), css::uno::TypeClass_SHORT }, { u"hyper", css::uno::TypeClass_HYPER },
{ std::u16string_view(u"unsigned short"), { u"unsigned hyper", css::uno::TypeClass_UNSIGNED_HYPER },
css::uno::TypeClass_UNSIGNED_SHORT }, { u"float", css::uno::TypeClass_FLOAT },
{ std::u16string_view(u"long"), css::uno::TypeClass_LONG }, { u"double", css::uno::TypeClass_DOUBLE },
{ std::u16string_view(u"unsigned long"), css::uno::TypeClass_UNSIGNED_LONG }, { u"char", css::uno::TypeClass_CHAR },
{ std::u16string_view(u"hyper"), css::uno::TypeClass_HYPER }, { u"string", css::uno::TypeClass_STRING },
{ std::u16string_view(u"unsigned hyper"), { u"type", css::uno::TypeClass_TYPE },
css::uno::TypeClass_UNSIGNED_HYPER }, { u"any", css::uno::TypeClass_ANY } };
{ std::u16string_view(u"float"), css::uno::TypeClass_FLOAT }, for (const auto& [ rName, rTypeClass ] : simple) {
{ std::u16string_view(u"double"), css::uno::TypeClass_DOUBLE }, if (name == rName) {
{ std::u16string_view(u"char"), css::uno::TypeClass_CHAR },
{ std::u16string_view(u"string"), css::uno::TypeClass_STRING },
{ std::u16string_view(u"type"), css::uno::TypeClass_TYPE },
{ std::u16string_view(u"any"), css::uno::TypeClass_ANY } };
for (std::size_t i = 0; i != SAL_N_ELEMENTS(simple); ++i) {
if (name == simple[i].name) {
return css::uno::makeAny< return css::uno::makeAny<
css::uno::Reference< css::reflection::XTypeDescription > >( css::uno::Reference< css::reflection::XTypeDescription > >(
new SimpleTypeDescription(simple[i].typeClass, name)); new SimpleTypeDescription(rTypeClass, name));
} }
} }
if (name.startsWith("[]")) { if (name.startsWith("[]")) {