gemini-code-assist[bot] commented on code in PR #453:
URL: https://github.com/apache/tvm-ffi/pull/453#discussion_r2810474060


##########
src/ffi/extra/reflection_extra.cc:
##########
@@ -133,11 +134,42 @@ inline void AccessPathRegisterReflection() {
            [](const AccessPath& self, const AccessPath& other) { return 
self->PathEqual(other); });
 }
 
+int64_t StructuralKeyHash(const Any& key) { return 
key.cast<StructuralKey>()->hash_i64; }

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   For better performance and consistency with `StructuralKeyEqual`, consider 
using `as<StructuralKeyObj>()` instead of `cast<StructuralKey>()`. `cast` 
creates a temporary `ObjectRef` which involves reference counting overhead, 
while `as` provides a direct pointer without this overhead. Given that this 
function is an `__any_hash__` hook, the `key` is guaranteed to be of the 
correct type, so a direct `as` is safe.
   
   ```suggestion
   int64_t StructuralKeyHash(const Any& key) { return 
key.as<StructuralKeyObj>()->hash_i64; }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to