What are some tips for optimizing jSoup?

What tips can be kept in mind to speed up jSoup? I am new to using jSoup and any tips on what I should do, what I should avoid, etc. It would be very helpful.

I just want to know some common things so that I don't slow down my own software.

For example, which is faster:

doc.select("[class=foo]:eq(0)").first() 

or

 doc.select("[class=foo]").first() 

or

 doc.select("[class=foo]:lt(1)").first() 

Such things.

+3
source share
1 answer

You can try this tip (taken from here ):

not big

 for (Element link : links) 

it's better

 int i; Element tempLink; for (i=0;i<links.size();i++) { tempLink = links.get(i); } 
+1
source

Source: https://habr.com/ru/post/919493/


All Articles