Repository: xbmc/xbmc
File: xbmc/TextureCacheJob.cpp (C++)

Code before:
      return true;
  }
  return false;
}

bool CTextureCacheJob::DoWork()
{
  if (ShouldCancel(0, 0))
    return false;

  // check whether we need cache the job anyway
  bool needsRecaching = false;
  std::string path(CServiceBroker::GetTextureCache()->CheckCachedImage(m_url, needsRecaching));
  if (!path.empty() && !needsRecaching)
    return false;
  if (CServiceBroker::GetTextureCache()->StartCacheImage(m_url))
    return CacheTexture();

  return false;
}

namespace
{
// Most PVR images use "additional_info" to signify 'ownership' of basic images for easy
// cache cleaning, rather than special generated images
bool IsPVROwnedImage(std::string additional_info)
{
  return additional_info == "pvrchannel_radio" || additional_info == "pvrchannel_tv" ||
         additional_info == "pvrprovider" || additional_info == "pvrrecording" ||
         StringUtils::StartsWith(additional_info, "epgtag_");
}

// DecodeImageURL can also set "additional_info" to 'flipped' for mirror images selected in
// the GUI, so is not a special generated image
bool IsControl(std::string additional_info)
{
  return additional_info == "flipped";
}

// special generated images and images served via HTTP should not be regularly checked for changes
bool ShouldCheckForChanges(std::string additional_info, std::string url)
{
  bool isSpecialImage =
      !additional_info.empty() && !IsControl(additional_info) && !IsPVROwnedImage(additional_info);
  if (isSpecialImage)
    return false;
  bool isHTTP = StringUtils::StartsWith(url, "http://") || StringUtils::StartsWith(url, "https://");
  return !isHTTP;
}
} // namespace


Review comment (refactor):
please pass by const ref also for the other helper functions
```suggestion
bool IsPVROwnedImage(const std::string& additional_info)
```

Code after:
      return true;
  }
  return false;
}

bool CTextureCacheJob::DoWork()
{
  if (ShouldCancel(0, 0))
    return false;

  // check whether we need cache the job anyway
  bool needsRecaching = false;
  std::string path(CServiceBroker::GetTextureCache()->CheckCachedImage(m_url, needsRecaching));
  if (!path.empty() && !needsRecaching)
    return false;
  if (CServiceBroker::GetTextureCache()->StartCacheImage(m_url))
    return CacheTexture();

  return false;
}

namespace
{
// Most PVR images use "additional_info" to signify 'ownership' of basic images for easy
// cache cleaning, rather than special generated images
bool IsPVROwnedImage(const std::string& additional_info)
{
  return additional_info == "pvrchannel_radio" || additional_info == "pvrchannel_tv" ||
         additional_info == "pvrprovider" || additional_info == "pvrrecording" ||
         StringUtils::StartsWith(additional_info, "epgtag_");
}

// DecodeImageURL can also set "additional_info" to 'flipped' for mirror images selected in
// the GUI, so is not a special generated image
bool IsControl(const std::string& additional_info)
{
  return additional_info == "flipped";
}

// special generated images and images served via HTTP should not be regularly checked for changes
bool ShouldCheckForChanges(const std::string& additional_info, const std::string& url)
{
  const bool isSpecialImage =
      !additional_info.empty() && !IsControl(additional_info) && !IsPVROwnedImage(additional_info);
  if (isSpecialImage)
    return false;

  const bool isHTTP =
      StringUtils::StartsWith(url, "http://") || StringUtils::StartsWith(url, "https://");
  return !isHTTP;
}