Skip to content

Conversation

@nxtum
Copy link
Contributor

@nxtum nxtum commented Oct 28, 2025

No description provided.

Copilot AI review requested due to automatic review settings October 28, 2025 22:09
@nxtum nxtum marked this pull request as draft October 28, 2025 22:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds equality comparison operators (operator== and operator!=) to JSON-related classes in Thunder's Core library, enabling value-based comparison of ArrayType, Variant, and VariantContainer objects.

Key Changes:

  • Implemented operator== and operator!= for ArrayType<ELEMENT> template class
  • Implemented operator== and operator!= for Variant class with type-specific comparisons
  • Implemented operator== and operator!= for VariantContainer class with key-value pair comparison
  • Added helper method FindValue() to VariantContainer for key-based value lookup
Comments suppressed due to low confidence (1)

Source/core/JSON.h:1

  • The newly added equality operators for Variant lack test coverage. Consider adding unit tests to verify correct behavior for all variant types (EMPTY, BOOLEAN, STRING, NUMBER, FLOAT, DOUBLE, ARRAY, OBJECT), including edge cases and type mismatches.
 /*

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +4997 to +4998
case type::OBJECT:
return Object() == other.Object();
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing OBJECT types by calling Object() on both sides performs string serialization and deserialization (via ToString() and FromString() as seen in lines 4969-4973), which is expensive. Consider caching the deserialized VariantContainer or implementing a more efficient comparison strategy.

Copilot uses AI. Check for mistakes.
@nxtum nxtum marked this pull request as ready for review October 29, 2025 09:15
Copilot AI review requested due to automatic review settings October 29, 2025 09:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 4982 to 5000
switch (_type) {
case type::EMPTY:
return true;
case type::BOOLEAN:
return Boolean() == other.Boolean();
case type::STRING:
return String() == other.String();
case type::NUMBER:
return Number() == other.Number();
case type::FLOAT:
return Float() == other.Float();
case type::DOUBLE:
return Double() == other.Double();
case type::ARRAY:
return Array() == other.Array();
case type::OBJECT:
return Object() == other.Object();
}
return false;
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The switch statement lacks a default case. While all enum values are covered, adding a default case that either asserts or returns false would make the code more robust against future enum additions and satisfy compiler warnings with -Wswitch-default.

Copilot uses AI. Check for mistakes.
@nxtum nxtum requested a review from sebaszm November 17, 2025 10:10
Copilot AI review requested due to automatic review settings November 17, 2025 10:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

case type::OBJECT:
return Object() == other.Object();
default:
ASSERT(false);
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default case contains an ASSERT(false) but still falls through to return false. Consider adding an explicit return statement after the ASSERT, or use ASSERT_UNREACHABLE() if available, to make the intended control flow clearer and avoid compiler warnings about missing return in some configurations.

Suggested change
ASSERT(false);
ASSERT(false);
return false;

Copilot uses AI. Check for mistakes.
Comment on lines +5003 to +5005
return Float() == other.Float();
case type::DOUBLE:
return Double() == other.Double();
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct floating-point equality comparison may produce unexpected results due to precision issues. Consider using an epsilon-based comparison for Float() and Double() types, or document that exact bitwise equality is intentional if that's the desired behavior.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants