From 8c0f46309bfe424cd86a7b273170e7380fbd678c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 4 Apr 2015 12:51:56 -0400 Subject: [PATCH] Variant: Return const refs rather than string copies --- src/Variant.cpp | 4 ++-- src/Variant.h | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Variant.cpp b/src/Variant.cpp index 80b5f228f..1f378b8f7 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -166,7 +166,7 @@ void Variant::source (const std::string& input) } //////////////////////////////////////////////////////////////////////////////// -std::string Variant::source () const +const std::string& Variant::source () const { return _source; } @@ -2174,7 +2174,7 @@ double Variant::get_real () const } //////////////////////////////////////////////////////////////////////////////// -std::string Variant::get_string () const +const std::string& Variant::get_string () const { return _string; } diff --git a/src/Variant.h b/src/Variant.h index 6780acefa..c733a0abe 100644 --- a/src/Variant.h +++ b/src/Variant.h @@ -53,7 +53,7 @@ public: ~Variant (); void source (const std::string&); - std::string source () const; + const std::string& source () const; Variant& operator= (const Variant&); @@ -99,12 +99,12 @@ public: int type (); bool trivial () const; - bool get_bool () const; - int get_integer () const; - double get_real () const; - std::string get_string () const; - time_t get_date () const; - time_t get_duration () const; + bool get_bool () const; + int get_integer () const; + double get_real () const; + const std::string& get_string () const; + time_t get_date () const; + time_t get_duration () const; private: enum type _type;