[Boost-bugs] [Boost C++ Libraries] #11663: No way to query file extension without allocating memory

Subject: [Boost-bugs] [Boost C++ Libraries] #11663: No way to query file extension without allocating memory
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-09-17 06:44:37


#11663: No way to query file extension without allocating memory
--------------------------------+--------------------------
 Reporter: matthew.chaplain@… | Owner: bemandawes
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: filesystem
  Version: Boost 1.57.0 | Severity: Optimization
 Keywords: |
--------------------------------+--------------------------
 the function .extension() returns an fs::path, containing a fresh string
 that contains the extension. On certain library implementations that
 don't implement the SSO -- or, I guess, for files with very long
 extensions -- there will be a memory allocation each time the function is
 called.

 That means that for solutions implementing search-by-extension such as is
 written in:

 http://stackoverflow.com/questions/11140483/how-to-get-list-of-files-
 with-a-specific-extension-in-a-given-folder

 there could be hundreds of memory allocations for just iterating a
 directory structure. IMO, there really shouldn't be.

 I propose adding the function bool path::has_extension(string const&)
 which can compare the extension in a memory-friendly way.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11663>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC