22
33#include " fmt/core.h"
44#include " ll/api/Logger.h"
5+ #include " ll/api/command/CommandRegistrar.h"
56#include " ll/api/memory/Closure.h"
67#include " ll/api/memory/Memory.h"
78#include " ll/api/utils/ErrorUtils.h"
3435#include < algorithm>
3536#include < cstddef>
3637#include < cstdint>
38+ #include < ll/api/command/CommandRegistrar.h>
3739#include < memory>
3840#include < sstream>
3941#include < stdexcept>
@@ -453,30 +455,24 @@ DynamicCommand::preSetup(CommandRegistry& registry, std::unique_ptr<class Dynami
453455 if (param.type == ParameterType::Enum) {
454456 // clone BDS's enum
455457 if (commandInstance->enumRanges .count (param.description ) == 0 ) {
456- auto namesInBds = registry.getEnumNames ();
457- auto iter = std::find (namesInBds.begin (), namesInBds.end (), param.description );
458- if (iter == namesInBds.end ())
459- throw std::runtime_error (
460- " Enum " + std::string (param.description ) + " not found in command and BDS"
461- );
462- commandInstance->setEnum (*iter, registry.getEnumValues (*iter));
458+ if (!ll::command::CommandRegistrar::getInstance ().hasEnum (param.description ))
459+ throw std::runtime_error (" Enum " + param.description + " not found in command and BDS" );
460+ commandInstance->setEnum (param.description , registry.getEnumValues (*iter));
463461 }
464462 } else if (param.type == ParameterType::SoftEnum) {
465463 // add empty Soft Enum if not found in command and BDS
466464 if (commandInstance->softEnums .count (param.description ) == 0 ) {
467- auto namesInBds = registry.getSoftEnumNames ();
468- auto iter = std::find (namesInBds.begin (), namesInBds.end (), param.description );
469- if (iter == namesInBds.end ()) commandInstance->setSoftEnum (param.description , {});
465+ if (!ll::command::CommandRegistrar::getInstance ().hasSoftEnum (param.description ))
466+ commandInstance->setSoftEnum (param.description , {});
470467 }
471468 }
472469 }
473470
474471 // fix enum name with prefix '_...' if Enum name is exists in BDS
475- auto namesInBds = registry.getEnumNames ();
476472 std::unordered_map<std::string_view, std::pair<size_t , size_t >> convertedEnumRanges;
477473 for (auto & [desc, range] : commandInstance->enumRanges ) {
478474 std::string fixedName = desc.data ();
479- while (std::find (namesInBds. begin (), namesInBds. end (), fixedName) != namesInBds. end ( )) {
475+ while (! ll::command::CommandRegistrar::getInstance (). hasEnum ( fixedName)) {
480476 fixedName.append (" _" );
481477 }
482478 std::string_view fixedView = desc;
@@ -881,8 +877,7 @@ std::string DynamicCommandInstance::setSoftEnum(std::string const& name, std::ve
881877 if (!hasRegistered ()) {
882878 softEnums.emplace (name, values);
883879 } else {
884- auto names = registry.getSoftEnumNames ();
885- if (std::find (names.begin (), names.end (), name) == names.end ()) {
880+ if (!ll::command::CommandRegistrar::getInstance ().hasSoftEnum (name)) {
886881 registry.addSoftEnum (name, values);
887882 return name;
888883 }
@@ -900,8 +895,7 @@ bool DynamicCommandInstance::addSoftEnumValues(std::string const& name, std::vec
900895 setSoftEnum (name, values);
901896 }
902897 } else {
903- auto names = registry.getSoftEnumNames ();
904- if (std::find (names.begin (), names.end (), name) == names.end ()) {
898+ if (!ll::command::CommandRegistrar::getInstance ().hasSoftEnum (name)) {
905899 registry.addSoftEnum (name, values);
906900 return true ;
907901 }
0 commit comments