-
-
Notifications
You must be signed in to change notification settings - Fork 903
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
jruby improvements + weaker xpath caching #1597
Conversation
Thank you for submitting this, @kares! Can you please rebase this off current master? It doesn't have 92768e0 in it, so the CI pipeline is failing when testing against libxml system libraries. See https://ci.nokogiri.org/teams/nokogiri-core/pipelines/nokogiri/jobs/ruby-2.4-system-pr/builds/3 for specifics. |
no need for a synchronized Hashtable here; size will be 4 99% of time
... loading reflectively makes no sense since the class is already loaded as its part of the method's signature (return type)
has been introduced before the xalan .jars where packed with the gem it was only necessary due changing Java version - no longer the case!
... from JRuby's RubyHash API so that we avoid all is1_9() checks
... much safer to reason about AND REVEALED SOME INTERNAL ISSUES !
... also re-format code spacing to match rest of the file
... (temporarily) removed the existing caching mechanism
we now make sure to only cache xpaths without binds or custom handlers ... it has been disabled in previous commit(s)
... since there's logic everywhere dealing with the case also do NOT initialize nodes with newEmptyArray and than append to it
... to potentially save one piece of (char[]) array copy-ing
(incl. previous commits) causes notably less garbage generation!
also faster due re-using a thread-cached encoder (resolves sparklemotion#1440)
also use enum values instead of wrapping it to a set (to find encoding)
830e5ea
to
377dde4
Compare
rebased and all 💚 now ... thanks for the feedback. numbers show that doc parsing is ~ 10% faster + xpath has gone 2x faster in some of the cases I tested. |
Yep, about to merge! Just writing CHANGELOG entries now. Thanks so much! |
managed to run into more common problems such as cloning non-cloneable (Java) objects.
a bit ugly pattern in general but for the rest of Ruby object cloning it would need a justification.
further I realized some xpath problems :
Integer
was not supported (resolved xpath function returning an int fails under jruby #1595)this is now avoided (such expressions always create a new xpath context) - they are less common.
xpath(expr)
still caches as before, but I realized the cache makesxpath()
not thread-safe #1596UPDATE: also added a fix for #1440 (also resolves #1281 which is a duplicate - had the same cause)