Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/coding
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2012-10-11 15:52:45 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:45:07 +0300
commit8918d30170eb2d32ad7fa10d52e5f47e1d8a74cf (patch)
tree3b4689bf427e75c37bb69e7265993c0bed30eae7 /coding
parentf56795bdca4c273332f10de6299abf3272a0ead3 (diff)
Fix dummy error in reading opt-string.
Diffstat (limited to 'coding')
-rw-r--r--coding/value_opt_string.hpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/coding/value_opt_string.hpp b/coding/value_opt_string.hpp
index 8ccf9c7f3c..1b197cd1ee 100644
--- a/coding/value_opt_string.hpp
+++ b/coding/value_opt_string.hpp
@@ -12,8 +12,6 @@ class StringNumericOptimal
{
string m_s;
- static const uint8_t numeric_bit = 1;
-
public:
inline bool operator== (StringNumericOptimal const & rhs) const
{
@@ -40,11 +38,16 @@ public:
inline bool IsEmpty() const { return m_s.empty(); }
inline string const & Get() const { return m_s; }
+ /// First uint64_t value is:
+ /// - a number if low control bit is 1;
+ /// - a string size-1 if low control bit is 0;
+
template <class TSink> void Write(TSink & sink) const
{
+ // If string is a number and we have space for control bit
uint64_t n;
if (strings::to_uint64(m_s, n) && ((n << 1) >> 1) == n)
- WriteVarUint(sink, ((n << 1) | numeric_bit));
+ WriteVarUint(sink, ((n << 1) | 1));
else
{
size_t const sz = m_s.size();
@@ -57,9 +60,9 @@ public:
template <class TSource> void Read(TSource & src)
{
- uint32_t sz = ReadVarUint<uint32_t>(src);
+ uint64_t sz = ReadVarUint<uint64_t>(src);
- if ((sz & numeric_bit) != 0)
+ if ((sz & 1) != 0)
m_s = strings::to_string(sz >> 1);
else
{