Repository: xbmc/xbmc
File: xbmc/settings/AdvancedSettings.cpp (C++)

Code before:
  }
}

void CAdvancedSettings::AddSettingsFile(const std::string &filename)
{
  m_settingsFiles.push_back(filename);
}

float CAdvancedSettings::GetLatencyTweak(float refreshrate, bool isHDREnabled)
{
  float delay = m_videoDefaultLatency;
  if (isHDREnabled)
    delay += m_videoDefaultHdrExtraLatency;

  for (const auto& videolatency : m_videoRefreshLatency)
  {
    if (refreshrate >= videolatency.refreshmin && refreshrate <= videolatency.refreshmax)
    {
      delay = videolatency.delay;

      if (isHDREnabled)
      {
        if (videolatency.hdrextradelay != 0.0f)
          delay += videolatency.hdrextradelay;
        else
          delay += m_videoDefaultHdrExtraLatency;
      } 
    }
  }
  return delay; // in milliseconds
}

void CAdvancedSettings::SetDebugMode(bool debug)
{
  if (debug)
  {
    int level = std::max(m_logLevelHint, LOG_LEVEL_DEBUG_FREEMEM);
    m_logLevel = level;
    CServiceBroker::GetLogging().SetLogLevel(level);
    CLog::Log(LOGINFO, "Enabled debug logging due to GUI setting. Level {}.", level);
  }
  else
  {
    int level = std::min(m_logLevelHint, LOG_LEVEL_DEBUG/*LOG_LEVEL_NORMAL*/);
    CLog::Log(LOGINFO, "Disabled debug logging due to GUI setting. Level {}.", level);
    m_logLevel = level;
    CServiceBroker::GetLogging().SetLogLevel(level);
  }
}

void CAdvancedSettings::SetExtraArtwork(const TiXmlElement* arttypes, std::vector<std::string>& artworkMap)

Review comment (performance):
When HDR is enabled and `videolatency.hdrextradelay == 0`, `m_videoDefaultHdrExtraLatency` is added twice.

Global latency already added before for loop, then is not need this `else` code.



Code after:
        extensions.erase(iPos,i->size()+1);
    }
  }
}

void CAdvancedSettings::AddSettingsFile(const std::string &filename)
{
  m_settingsFiles.push_back(filename);
}

float CAdvancedSettings::GetLatencyTweak(float refreshrate, bool isHDREnabled)
{
  float delay{};
  const auto& latency =
      std::find_if(m_videoRefreshLatency.cbegin(), m_videoRefreshLatency.cend(),
                   [refreshrate](const auto& param)
                   { return refreshrate >= param.refreshmin && refreshrate <= param.refreshmax; });

  if (latency != m_videoRefreshLatency.cend()) //refresh rate specific setting is found
  {
    delay = latency->delay == 0.0f ? m_videoDefaultLatency : latency->delay;
    if (isHDREnabled)
      delay +=
          latency->hdrextradelay == 0.0f ? m_videoDefaultHdrExtraLatency : latency->hdrextradelay;
  }
  else //apply default delay settings
  {
    delay = isHDREnabled ? m_videoDefaultLatency + m_videoDefaultHdrExtraLatency
                         : m_videoDefaultLatency;
  }
  return delay; // in milliseconds
}

void CAdvancedSettings::SetDebugMode(bool debug)
{
  if (debug)
  {
    int level = std::max(m_logLevelHint, LOG_LEVEL_DEBUG_FREEMEM);
    m_logLevel = level;
    CServiceBroker::GetLogging().SetLogLevel(level);
    CLog::Log(LOGINFO, "Enabled debug logging due to GUI setting. Level {}.", level);
  }
  else
  {
    int level = std::min(m_logLevelHint, LOG_LEVEL_DEBUG/*LOG_LEVEL_NORMAL*/);
    CLog::Log(LOGINFO, "Disabled debug logging due to GUI setting. Level {}.", level);
    m_logLevel = level;
    CServiceBroker::GetLogging().SetLogLevel(level);
  }
}