-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace ArrayList .equals()
method with ==
to compare the objects
#447
base: master
Are you sure you want to change the base?
Conversation
MemoryManagerReferenceHandler.v8HandleDisposed method is already implemented with Iterator to compare the object using `==` instead of `.equals`. Therefore, MemoryManagerReferenceHandler.v8HandleDisposed can be used rather than ArrayList.remove to remove object from references array. Fix #444
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few small comments. I wonder if you can add a test case for this.
@@ -92,7 +92,7 @@ public boolean isReleased() { | |||
*/ | |||
public void release() { | |||
v8.getLocker().checkThread(); | |||
if (released) { | |||
if (isReleased()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change this as part of this commit. We can use the field without the accessor for internal calls.
@@ -109,7 +109,7 @@ public void release() { | |||
} | |||
|
|||
private void checkReleased() { | |||
if (released) { | |||
if (isReleased()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. See above
@@ -73,7 +73,7 @@ public int getObjectReferenceCount() { | |||
public void persist(final V8Value object) { | |||
v8.getLocker().checkThread(); | |||
checkReleased(); | |||
references.remove(object); | |||
memoryManagerReferenceHandler.v8HandleDisposed(object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you include a test case in the MemoryManagerTest that gets the same V8ObjectTwice (so there are two copies of it) and then one is persisted? After we release the MemoryManager one should still remain. I can help you with this if you need help.
Unit tests verify the following cases: * Persisted object decrease MemoryManager object reference count * Duplicated object is not managed by MemoryManager when persisted
MemoryManagerReferenceHandler.v8HandleDisposed method is already
implemented with Iterator to compare the object using
==
instead of.equals
. Therefore,MemoryManagerReferenceHandler.v8HandleDisposed can be used rather than
ArrayList.remove to remove object from references array.
Fix #444