perf: Use LinkedHashSet instead of array backed collection in ObjectsStore#98
perf: Use LinkedHashSet instead of array backed collection in ObjectsStore#98wchill wants to merge 1 commit intoREAndroid:mainfrom
Conversation
|
Thank you for this PR! if-eqz v0, :cond_0
if-nez v1, :cond_0
....
:cond_0
:cond_0
In smali we don't print duplicate You are creating ArrayList for every sort, may not dispose fast during garbage collection I must make a test for this and merge latter. BTW: The root cause of this problem most likely r8 ignores stripping dead debug line numbers. Sometime you may find several hundred line numbers for single instruction. Check with |
|
I did originally use an IdentityHashMap to implement this, but the issue is that the contains() check on ArrayCollection actually checks for both reference equality and equality using equals(). So while IdentityHashMap might work, I did not explore it further because the semantics are not the same. Creation of an ArrayList on each sort did not seem to be an issue in practice, unless you are attempting to sort every time something is added/removed to the data structure (which would be a problem in itself). |
|
I have to study it further, allow me some time |
Fixes #97
ObjectsStore does not provide an API for random access, so there is no point in using a list or array because we get no benefit from constant-time random access, as long as we can guarantee ordering (which LinkedHashSet does). This speeds up add, remove, and contains operations from O(n) to O(1), which prevents the degenerate case mentioned in #97.
The underlying data structure is not exposed (because all accesses are proxied through ObjectsStore), so we don't need to worry about the extra functions that ObjectsList/ArrayCollection provides.
Speedup: approximately 4 minutes spent for decode/modify/encode/zipalign/sign total -> 26 seconds on a Ryzen AI 9 HX 370.