Inefficient internal content(Element) method
lukaseder opened this issue · 0 comments
lukaseder commented
There's an internal content(Element)
method with a TODO that does not yet have an issue associated with it:
// TODO: Check this code's efficiency
String name = element.getTagName();
return Util.toString(element).replaceAll("(?s)^<" + name + "(?:[^>]*)>(.*)</" + name + ">$", "$1");
This is very obviously inefficient. We cannot cache the regular expression, but we can traverse the string without resorting to regexes, as the regex logic is rather simple.