From ea3bbd0e85cf8cfa27969792bf4440ca60e28cc4 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Mon, 23 Dec 2019 04:16:47 -0600 Subject: [PATCH] Datafile: allLines() can return const reference instead of copy. Not only does this eliminate the need to copy the stings to the caller, it will also eliminate the need for any iterators over the entries in the Database from having to hold a copy of the lines from the Datafile. Related to #245. --- src/Datafile.cpp | 2 +- src/Datafile.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Datafile.cpp b/src/Datafile.cpp index f4d769c0..22fe00ef 100644 --- a/src/Datafile.cpp +++ b/src/Datafile.cpp @@ -77,7 +77,7 @@ std::string Datafile::lastLine () } //////////////////////////////////////////////////////////////////////////////// -std::vector Datafile::allLines () +const std::vector & Datafile::allLines () { if (! _lines_loaded) load_lines (); diff --git a/src/Datafile.h b/src/Datafile.h index 1bf638c4..f73c1d81 100644 --- a/src/Datafile.h +++ b/src/Datafile.h @@ -41,7 +41,7 @@ public: std::string name () const; std::string lastLine (); - std::vector allLines (); + const std::vector & allLines (); void addInterval (const Interval&); void deleteInterval (const Interval&);