Good day, Evgeny. No. Handle just another level of indirection. So this code checks if any of handles is empty (not referencing any objects) and if both are not it checks if they reference the same object. Your variant would trigger an assertion if any of handles is empty.
yours, anton. On Thu, Apr 1, 2010 at 3:47 PM, Evgeny Astigeevich <[email protected]> wrote: > Hi, > > I'm trying to figure out the code of v8::Handle: > > template <class S> bool operator==(Handle<S> that) const { > internal::Object** a = > reinterpret_cast<internal::Object**>(**this); > internal::Object** b = > reinterpret_cast<internal::Object**>(*that); > if (a == 0) return b == 0; > if (b == 0) return false; > return *a == *b; > } > > The overloaded operator '==' returns true when handles contain the > same value. > > Why is it written in such a way? Is it a workaround of compiler bugs? > Does not the following code work: > > template <class S> bool operator==(Handle<S> that) const { > return reinterpret_cast<internal::Object*>(**this) == > reinterpret_cast<internal::Object*>(*that); > } > > Best regards, > Evgeny Astigeevich. > > -- > v8-dev mailing list > [email protected] > http://groups.google.com/group/v8-dev > > To unsubscribe, reply using "remove me" as the subject. > -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
