From 34e8a2f0f67541479141602da0ab76c1e6ac2cdc Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Sun, 23 May 2021 12:01:04 +0100 Subject: [PATCH] simplify --- src/util/zstring.cpp | 10 ++-------- src/util/zstring.h | 6 +++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/util/zstring.cpp b/src/util/zstring.cpp index d5f123533..46c9d9fce 100644 --- a/src/util/zstring.cpp +++ b/src/util/zstring.cpp @@ -276,16 +276,10 @@ bool operator<(const zstring& lhs, const zstring& rhs) { for (unsigned i = 0; i < len; ++i) { unsigned Li = lhs[i]; unsigned Ri = rhs[i]; - if (Li < Ri) { - return true; - } - else if (Li > Ri) { - return false; - } + if (Li != Ri) + return Li < Ri; } // at this point, all compared characters are equal, // so decide based on the relative lengths return lhs.length() < rhs.length(); } - - diff --git a/src/util/zstring.h b/src/util/zstring.h index 7531390c8..a15d1b03d 100644 --- a/src/util/zstring.h +++ b/src/util/zstring.h @@ -16,14 +16,14 @@ Author: --*/ #pragma once +#include #include -#include "util/vector.h" #include "util/buffer.h" #include "util/rational.h" class zstring { private: - buffer m_buffer; + buffer m_buffer; bool well_formed() const; bool uses_unicode() const; bool is_escape_char(char const *& s, unsigned& result); @@ -32,7 +32,7 @@ public: static unsigned unicode_num_bits() { return 18; } static unsigned ascii_max_char() { return 255; } static unsigned ascii_num_bits() { return 8; } - zstring() {} + zstring() = default; zstring(char const* s); zstring(const std::string &str) : zstring(str.c_str()) {} zstring(rational const& r): zstring(r.to_string()) {}