From 2499d9ff0c55a445a62643028a9d3bc9faf1195a Mon Sep 17 00:00:00 2001 From: наб Date: Thu, 23 Jan 2025 19:33:57 +0100 Subject: string{=> _view} flExtension(string{=> _view}) --- apt-pkg/contrib/fileutl.cc | 14 +++++++------- apt-pkg/contrib/fileutl.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index e57662abc..1a417f7e2 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -485,7 +485,7 @@ std::vector GetListOfFilesInDir(string const &Dir, std::vector c { if (RealFileExists(File) == false) { - string d_ext = flExtension(Ent->d_name); + auto d_ext = flExtension(Ent->d_name); // do not show ignoration warnings for directories if (( #ifdef _DIRENT_HAVE_D_TYPE @@ -505,7 +505,7 @@ std::vector GetListOfFilesInDir(string const &Dir, std::vector c // extensions given -> "" extension allows no extension if (Ext.empty() == false) { - string d_ext = flExtension(Ent->d_name); + auto d_ext = flExtension(Ent->d_name); if (d_ext == Ent->d_name) // no extension { if (std::find(Ext.begin(), Ext.end(), "") == Ext.end()) @@ -694,13 +694,13 @@ string flNotFile(string File) // flExtension - Return the extension for the file /*{{{*/ // --------------------------------------------------------------------- /* */ -string flExtension(string File) +string_view flExtension(string_view File) { - string::size_type Res = File.rfind('.'); - if (Res == string::npos) + string_view::size_type Res = File.rfind('.'); + if (Res == string_view::npos) return File; - Res++; - return string(File,Res); + File.remove_prefix(Res + 1); + return File; } /*}}}*/ // flNoLink - If file is a symlink then deref it /*{{{*/ diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 4ecddbf86..52f9bc657 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -255,7 +255,7 @@ APT_PUBLIC bool DropPrivileges(); APT_PUBLIC std::string flNotDir(std::string File); APT_PUBLIC std::string flNotFile(std::string File); APT_PUBLIC std::string flNoLink(std::string File); -APT_PUBLIC std::string flExtension(std::string File); +APT_PUBLIC std::string_view flExtension(std::string_view File); APT_PUBLIC std::string flCombine(std::string Dir,std::string File); /** \brief Takes a file path and returns the absolute path -- cgit v1.2.3-70-g09d2