Repository: xbmc/xbmc
File: xbmc/filesystem/NFSDirectory.cpp (C++)

Code before:
  {
    CLog::Log(LOGERROR, "Failed to open({}) {}", strDirName,
              nfs_get_error(gNfsConnection.GetNfsContext()));
    return false;
  }
  lock.unlock();

  const std::vector<std::string> exclusions = {".", "..", "lost+found"};
  const auto notExcluded = exclusions.end();

  std::string myStrPath(url.Get());
  URIUtils::AddSlashAtEnd(myStrPath);
  URIUtils::AddSlashAtEnd(strDirName);

  std::string resolvedPath;
  std::vector<CFileItemPtr> fileItems;
  struct nfsdirent* dirent = NULL;
  while ((dirent = nfs_readdir(gNfsConnection.GetNfsContext(), nfsdir)) != NULL)
  {
    const std::string& strName = dirent->name;

    //resolve symlinks
    //resolve symlink changes dirent and strName
    const bool isSymLink = dirent->type == NF3LNK;
    if (isSymLink && !ResolveSymlink(strDirName, dirent, resolvedPath))
      continue;

    if (std::ranges::find(exclusions, strName) == notExcluded)
    {
      const bool bIsDir = dirent->type == NF3DIR;

      std::string path = isSymLink ? resolvedPath : (myStrPath + strName);
      if (bIsDir)
        URIUtils::AddSlashAtEnd(path);

      CFileItemPtr& pItem = fileItems.emplace_back(std::make_shared<CFileItem>(strName));
      pItem->SetDateTime(GetDirEntryTime(dirent));
      pItem->SetSize(dirent->size);
      pItem->SetFolder(bIsDir);
      pItem->SetPath(path);
      if (strName[0] == '.')
        pItem->SetProperty("file:hidden", true);
    }
  }
  items.AddItems(fileItems);

  lock.lock();
  nfs_closedir(gNfsConnection.GetNfsContext(), nfsdir); //close the dir
  lock.unlock();
  return true;
}

Review comment (suggestion):
This seems a bit overkilling, use simple:

```c++
 if (strName == "." || strName == ".." || strName == "lost + found")
   continue;
```

Is more readable and even faster --> tested while loop with ~3600 files:

std::ranges::find --> **~36 ms**
plain compare and continue --> **~22 ms**

(tested several times and ms varies few up/down but always is faster "continue" variant)




Code after:
  }
  lock.unlock();

  std::string myStrPath(url.Get());
  URIUtils::AddSlashAtEnd(myStrPath);
  URIUtils::AddSlashAtEnd(strDirName);

  std::string resolvedPath;
  std::vector<CFileItemPtr> fileItems;
  struct nfsdirent* dirent = nullptr;
  while ((dirent = nfs_readdir(gNfsConnection.GetNfsContext(), nfsdir)) != nullptr)
  {
    const std::string& name = dirent->name;

    //resolve symlinks
    //resolve symlink changes dirent and name
    const bool isSymLink = dirent->type == NF3LNK;
    if (isSymLink && !ResolveSymlink(strDirName, dirent, resolvedPath))
      continue;

    if (name == "." || name == ".." || name == "lost+found")
      continue;

    const bool isDir = dirent->type == NF3DIR;

    std::string path = isSymLink ? resolvedPath : (myStrPath + name);
    if (isDir)
      URIUtils::AddSlashAtEnd(path);

    auto& item = fileItems.emplace_back(std::make_shared<CFileItem>(name));
    item->SetPath(path);
    item->SetDateTime(GetDirEntryTime(dirent));
    item->SetFolder(isDir);
    item->SetSize(dirent->size);

    if (name[0] == '.')
      item->SetProperty("file:hidden", true);
  }
  items.AddItems(std::move(fileItems));

  lock.lock();
  nfs_closedir(gNfsConnection.GetNfsContext(), nfsdir); //close the dir
  lock.unlock();
  return true;
}

bool CNFSDirectory::Create(const CURL& url2)
{
  int ret = 0;
  bool success=true;