Repository: xbmc/xbmc
File: xbmc/guilib/GUIIncludes.cpp (C++)

Code before:
};
static_assert(std::ranges::is_sorted(CONSTANT_ATTRIBUTES));

static constexpr std::array<std::string_view, 35> CONSTANT_NODES = {
    "bordersize",  "bottom",     "centerbottom",  "centerleft", "centerright", "centertop",
    "depth",       "fadetime",   "focusposition", "height",     "itemgap",     "left",
    "movement",    "offsetx",    "offsety",       "pauseatend", "posx",        "posy",
    "radioheight", "radioposx",  "radioposy",     "radiowidth", "right",       "sliderheight",
    "sliderwidth", "spinheight", "spinposx",      "spinposy",   "spinwidth",   "textoffsetx",
    "textoffsety", "textwidth",  "timeperimage",  "top",        "width",
};
static_assert(std::ranges::is_sorted(CONSTANT_NODES));

static constexpr std::string_view EXPRESSION_ATTRIBUTE = "condition";

static constexpr std::array<std::string_view, 4> EXPRESSION_NODES = {
    "enable",
    "selected",
    "usealttexture",
    "visible",
};
static_assert(std::ranges::is_sorted(EXPRESSION_NODES));

static bool Contains(auto&& container, std::string_view item)
{
  return std::ranges::binary_search(container, item);
}

CGUIIncludes::CGUIIncludes() = default;

CGUIIncludes::~CGUIIncludes() = default;

void CGUIIncludes::Clear()
{
  m_includes.clear();
  m_defaults.clear();
  m_constants.clear();
  m_skinvariables.clear();
  m_files.clear();
  m_expressions.clear();
}

void CGUIIncludes::Load(const std::string &file)
{
  if (!Load_Internal(file))
    return;
  FlattenExpressions();
  FlattenSkinVariableConditions();
}

bool CGUIIncludes::Load_Internal(const std::string &file)

Review comment (suggestion):
Now that you changed the approach and the std lib function returns a boolean, maybe it's not necessary to have a function for this anymore and it will not be changed to std::ranges::contains later.

Code after:
};
static_assert(std::ranges::is_sorted(CONSTANT_ATTRIBUTES));

static constexpr std::array<std::string_view, 35> CONSTANT_NODES = {
    "bordersize",  "bottom",     "centerbottom",  "centerleft", "centerright", "centertop",
    "depth",       "fadetime",   "focusposition", "height",     "itemgap",     "left",
    "movement",    "offsetx",    "offsety",       "pauseatend", "posx",        "posy",
    "radioheight", "radioposx",  "radioposy",     "radiowidth", "right",       "sliderheight",
    "sliderwidth", "spinheight", "spinposx",      "spinposy",   "spinwidth",   "textoffsetx",
    "textoffsety", "textwidth",  "timeperimage",  "top",        "width",
};
static_assert(std::ranges::is_sorted(CONSTANT_NODES));

static constexpr std::string_view EXPRESSION_ATTRIBUTE = "condition";

static constexpr std::array<std::string_view, 4> EXPRESSION_NODES = {
    "enable",
    "selected",
    "usealttexture",
    "visible",
};
static_assert(std::ranges::is_sorted(EXPRESSION_NODES));

CGUIIncludes::CGUIIncludes() = default;

CGUIIncludes::~CGUIIncludes() = default;

void CGUIIncludes::Clear()
{
  m_includes.clear();
  m_defaults.clear();
  m_constants.clear();
  m_skinvariables.clear();
  m_files.clear();
  m_expressions.clear();
}

void CGUIIncludes::Load(const std::string &file)
{
  if (!Load_Internal(file))
    return;
  FlattenExpressions();
  FlattenSkinVariableConditions();
}

bool CGUIIncludes::Load_Internal(const std::string &file)
{
  // check to see if we already have this loaded
  if (HasLoaded(file))
    return true;