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

Code before:
        value = CURL(value).GetWithoutUserDetails();

        if (info.m_info == LISTITEM_FOLDERNAME)
        {
          URIUtils::RemoveSlashAtEnd(value);
          value = URIUtils::GetFileName(value);
        }
        return true;
      case LISTITEM_FILENAME_AND_PATH:
      case LISTITEM_DECODED_FILENAME_AND_PATH:
        if (VIDEO::IsVideoDb(*item))
          value = tag->m_strFileNameAndPath;
        else if (item->HasMusicInfoTag()) // special handling for music videos, which have both a videotag and a musictag
          break;
        else
          value = item->GetPath();

        value = CURL(value).GetWithoutUserDetails();

        // Decode path for readability
        // Loop up to 3 times as each call to CURL::Decode() decodes one 'layer'
        // ie. bluray://udf://smb:// would require 2 passes to make fully human-readable
        if (info.m_info == LISTITEM_DECODED_FILENAME_AND_PATH)
          for (unsigned int i = 0; i < MAX_DECODE_PASSES; ++i)
            if (value.find('%') != std::string::npos)
              value = CURL::Decode(value);

        return true;
      case LISTITEM_VIDEO_HDR_TYPE:
        value = tag->m_streamDetails.GetVideoHdrType();
        return true;
      case LISTITEM_LABEL:
      {
        //! @todo get rid of "videos with versions as folder" hack!

        // special casing for "show videos with multiple versions as folders", where the label
        // should be the video version, not the movie title.
        if (!item->HasVideoVersions())
          break;

        CGUIWindow* videoNav{
            CServiceBroker::GetGUI()->GetWindowManager().GetWindow(WINDOW_VIDEO_NAV)};
        if (videoNav && videoNav->GetProperty("VideoVersionsFolderView").asBoolean() &&
            videoNav->IsActive())
        {
          value = tag->GetAssetInfo().GetTitle();
          return true;
        }
        break;
      }
    }

Review comment (performance):
Shouldn't the absence of % be part of the for loop stop condition?
I can imagine a case with 4 layers if the iso was zipped - not sure it would actually ever happen.
For performance reasons, would it make sense to apply only to bluray (or a short list of protocols)? I didn't check if Decode is expensive.
This function is called for every rendered frame iirc.

Code after:
        if (info.m_info == LISTITEM_FOLDERNAME)
        {
          URIUtils::RemoveSlashAtEnd(value);
          value = URIUtils::GetFileName(value);
        }
        return true;
      case LISTITEM_FILENAME_AND_PATH:
      case LISTITEM_DECODED_FILENAME_AND_PATH:
        if (VIDEO::IsVideoDb(*item))
          value = tag->m_strFileNameAndPath;
        else if (item->HasMusicInfoTag()) // special handling for music videos, which have both a videotag and a musictag
          break;
        else
          value = item->GetPath();

        value = CURL(value).GetWithoutUserDetails();

        // Decode path for readability
        // Loop up to MAX_DECODE_PASSES times as each call to CURL::Decode() decodes one 'layer'
        // ie. bluray://udf://smb:// would require 2 passes to make fully human-readable
        if (info.m_info == LISTITEM_DECODED_FILENAME_AND_PATH)
        {
          static constexpr unsigned int MAX_DECODE_PASSES = 5;
          for (unsigned int i = 0; value.find('%') != std::string::npos && i < MAX_DECODE_PASSES;
               ++i)
            value = CURL::Decode(value);
        }

        return true;
      case LISTITEM_VIDEO_HDR_TYPE:
        value = tag->m_streamDetails.GetVideoHdrType();
        return true;
      case LISTITEM_LABEL:
      {
        //! @todo get rid of "videos with versions as folder" hack!

        // special casing for "show videos with multiple versions as folders", where the label
        // should be the video version, not the movie title.
        if (!item->HasVideoVersions())
          break;

        CGUIWindow* videoNav{
            CServiceBroker::GetGUI()->GetWindowManager().GetWindow(WINDOW_VIDEO_NAV)};
        if (videoNav && videoNav->GetProperty("VideoVersionsFolderView").asBoolean() &&
            videoNav->IsActive())
        {
          value = tag->GetAssetInfo().GetTitle();
          return true;
        }
        break;
      }