From 33a63ec13cb9d595c86c7218764a986642ae3dc8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 3 Jun 2016 00:14:37 +0100 Subject: Copy-free getRange in ebuild cache parser --- gentoobrowse-api/service/utils/ebuildCacheParser.cpp | 10 ++++++++++ gentoobrowse-api/service/utils/ebuildCacheParser.h | 1 + 2 files changed, 11 insertions(+) diff --git a/gentoobrowse-api/service/utils/ebuildCacheParser.cpp b/gentoobrowse-api/service/utils/ebuildCacheParser.cpp index ad894db..068d10b 100644 --- a/gentoobrowse-api/service/utils/ebuildCacheParser.cpp +++ b/gentoobrowse-api/service/utils/ebuildCacheParser.cpp @@ -29,6 +29,16 @@ namespace Gentoo { } return Glib::ustring(kvi->second.first, kvi->second.second); } + + boost::optional + EbuildCacheParser::getRange(const std::string & key) const + { + auto kvi = kvs.find(key); + if (kvi == kvs.end()) { + return boost::optional(); + } + return kvi->second; + } } } diff --git a/gentoobrowse-api/service/utils/ebuildCacheParser.h b/gentoobrowse-api/service/utils/ebuildCacheParser.h index e9f1dfc..c7449c7 100644 --- a/gentoobrowse-api/service/utils/ebuildCacheParser.h +++ b/gentoobrowse-api/service/utils/ebuildCacheParser.h @@ -17,6 +17,7 @@ namespace Gentoo { EbuildCacheParser(const boost::filesystem::path & p); boost::optional get(const std::string & key) const; + boost::optional getRange(const std::string & key) const; private: KVs kvs; -- cgit v1.2.3