From 30748b957f1fbce6c79c7ac48e8b377cd6c7fd5a Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 27 Mar 2020 09:16:06 +1100 Subject: Avoid casts by returning size_t from GetExpanded. --- lexlib/PropSetSimple.cxx | 4 ++-- lexlib/PropSetSimple.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lexlib') diff --git a/lexlib/PropSetSimple.cxx b/lexlib/PropSetSimple.cxx index 5ce353c71..6e1312527 100644 --- a/lexlib/PropSetSimple.cxx +++ b/lexlib/PropSetSimple.cxx @@ -137,10 +137,10 @@ static int ExpandAllInPlace(const PropSetSimple &props, std::string &withVars, i return maxExpands; } -int PropSetSimple::GetExpanded(const char *key, char *result) const { +size_t PropSetSimple::GetExpanded(const char *key, char *result) const { std::string val = Get(key); ExpandAllInPlace(*this, val, 100, VarChain(key)); - const int n = static_cast(val.size()); + const size_t n = val.size(); if (result) { memcpy(result, val.c_str(), n+1); } diff --git a/lexlib/PropSetSimple.h b/lexlib/PropSetSimple.h index ba4e42446..d4a5b2243 100644 --- a/lexlib/PropSetSimple.h +++ b/lexlib/PropSetSimple.h @@ -19,7 +19,7 @@ public: void Set(const char *key, const char *val, size_t lenKey, size_t lenVal); void SetMultiple(const char *); const char *Get(const char *key) const; - int GetExpanded(const char *key, char *result) const; + size_t GetExpanded(const char *key, char *result) const; int GetInt(const char *key, int defaultValue=0) const; }; -- cgit v1.2.3