Closed vstelmakh closed 3 years ago
Is UrlHilight more performant than Linkify?
Is UrlHilight more performant than Linkify?
I haven't done much comparison but for some dummy input text (32860 chars, contains 52 urls of different complexity), on Intel Core i7-6700 CPU @ 3.40GHz, PHP 7.4.10, I got next results:
Results could vary, depends on input content and url amount, but generally it's slower. That's the downside of covering more cases.
But if you compare the results, Linkify would not do proper matching, and mess with some a
tags. For example:
Original text: https://user:password@example.com/some/path?var1=1&var2=abc#anchor
Linkify: <a href="https://user: <a href="mailto:password@example.com">password@example.com</a>/some/path?var1=1&var2=abc#anchor">https://user: <a href="mailto:password@example.com">password@example.com</a>/some/path?var1=1&var2=abc#anchor</a>
Url highlight <a href="https://user:password@example.com/some/path?var1=1&var2=abc#anchor ">https://user:password@example.com/some/path?var1=1&var2=abc#anchor </a>
See full results html in attachment: results.zip. It's enough to open results in different browser tabs, to see the difference.
@RyanThompson Are you interested in this changes? Should I resolve the conflicts or close the PR?
Same as #706, but for v2 branch. Additionally extracted and refactored
humanize
andtruncate
toStringHelper
class. This gives possibility to add unit tests.linkify
- changed Linkify library to Url highlighthumanize
- replacedpreg_replace
bystr_replace
truncate
- refactored to properly handle unicodeAdded unit tests for all mentioned above.
Not sure if this is a direction how you plan to have it, but at least, could be usefull as an ideas/code parts.