From 7484b5a22f5ddd215e1a94a75f14edb86b794e9c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 16 Jun 2014 18:38:43 -0400 Subject: [PATCH] Variant - Updated operator< to handle trivial values. --- src/Variant.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Variant.cpp b/src/Variant.cpp index bcec3ab54..94d135582 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -296,11 +296,25 @@ bool Variant::operator< (const Variant& other) const } else { + if (left.trivial () || right.trivial ()) + return false; + return left._string < right._string; } - case type_date: left.cast (type_date); return left._date < right._date; - case type_duration: left.cast (type_duration); return left._duration < right._duration; + case type_date: + if (left.trivial () || right.trivial ()) + return false; + + left.cast (type_date); + return left._date < right._date; + + case type_duration: + if (left.trivial () || right.trivial ()) + return false; + + left.cast (type_duration); + return left._duration < right._duration; } break; @@ -316,10 +330,10 @@ bool Variant::operator< (const Variant& other) const case type_string: case type_date: case type_duration: - right.cast (type_date); - if (left._date == 0 || right._date == 0) + if (left.trivial () || right.trivial ()) return false; + right.cast (type_date); return left._date < right._date; } break; @@ -336,10 +350,10 @@ bool Variant::operator< (const Variant& other) const case type_string: case type_date: case type_duration: - right.cast (type_duration); - if (left._duration == 0 || right._duration == 0) + if (left.trivial () || right.trivial ()) return false; + right.cast (type_duration); return left._duration < right._duration; } break;