Skip to content

Commit 75b9e4a

Browse files
authored
Initialize url pattern matcher only when needed (#6836)
1 parent 46edbfb commit 75b9e4a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

api/src/org/labkey/api/util/PageFlowUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static public String filter(CharSequence s, boolean encodeSpace, boolean encodeL
221221
StringBuilder sb = new StringBuilder(2 * len);
222222
boolean newline = false;
223223

224-
Matcher urlMatcher = urlPatternStart.matcher(s);
224+
CachingSupplier<Matcher> urlMatcher = new CachingSupplier<>(() -> urlPatternStart.matcher(s));
225225

226226
for (int i = 0; i < len; ++i)
227227
{
@@ -281,10 +281,10 @@ else if (newline)
281281
{
282282
if (StringUtilsLabKey.startsWithURL(s.subSequence(i, Math.min(s.length(),i+10))))
283283
{
284-
urlMatcher.region(i, s.length());
285-
if (urlMatcher.lookingAt())
284+
urlMatcher.get().region(i, s.length());
285+
if (urlMatcher.get().lookingAt())
286286
{
287-
String href = urlMatcher.group(1);
287+
String href = urlMatcher.get().group(1);
288288
if (href.endsWith("."))
289289
href = href.substring(0, href.length() - 1);
290290
// for html/xml careful of " and "> and "/>

0 commit comments

Comments
 (0)