From 739bf3a75622a303bf869de15b8dd0783adba804 Mon Sep 17 00:00:00 2001 From: Nathan Burles Date: Mon, 1 Aug 2016 16:31:48 +0100 Subject: [PATCH] Compare contents in LexerATNConfig::operator== --- runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp | 5 ++++- runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp | 4 ++++ runtime/Cpp/runtime/src/atn/LexerActionExecutor.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp b/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp index df6c26550..3bfe5b492 100755 --- a/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp +++ b/runtime/Cpp/runtime/src/atn/LexerATNConfig.cpp @@ -89,10 +89,13 @@ size_t LexerATNConfig::hashCode() const { bool LexerATNConfig::operator == (const LexerATNConfig& other) const { + if (this == &other) + return true; + if (_passedThroughNonGreedyDecision != other._passedThroughNonGreedyDecision) return false; - if (_lexerActionExecutor != other._lexerActionExecutor) { + if (_lexerActionExecutor != other._lexerActionExecutor && (_lexerActionExecutor != nullptr && *_lexerActionExecutor != *(other._lexerActionExecutor))) { return false; } diff --git a/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp b/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp index 91198b074..cf9d40a5d 100755 --- a/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp +++ b/runtime/Cpp/runtime/src/atn/LexerActionExecutor.cpp @@ -115,6 +115,10 @@ bool LexerActionExecutor::operator == (const LexerActionExecutor &obj) const { return _hashCode == obj._hashCode && Arrays::equals(_lexerActions, obj._lexerActions); } +bool LexerActionExecutor::operator != (const LexerActionExecutor &obj) const { + return !operator==(obj); +} + size_t LexerActionExecutor::generateHashCode() const { size_t hash = MurmurHash::initialize(); for (auto lexerAction : _lexerActions) { diff --git a/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h b/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h index 0b5e6d7ee..f707e57b2 100755 --- a/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h +++ b/runtime/Cpp/runtime/src/atn/LexerActionExecutor.h @@ -125,6 +125,7 @@ namespace atn { virtual size_t hashCode() const; virtual bool operator == (const LexerActionExecutor &obj) const; + virtual bool operator != (const LexerActionExecutor &obj) const; private: const std::vector> _lexerActions;