Compile Url match regex once and not on every use

Needed for #2146.
This commit is contained in:
agnostic-apollo
2021-06-30 03:18:44 +05:00
parent 69bebb5916
commit 28b9f93d13
4 changed files with 107 additions and 91 deletions

View File

@@ -21,6 +21,7 @@ import android.widget.Toast;
import com.termux.R;
import com.termux.app.TermuxActivity;
import com.termux.shared.data.UrlUtils;
import com.termux.shared.shell.ShellUtils;
import com.termux.shared.terminal.TermuxTerminalViewClientBase;
import com.termux.shared.termux.TermuxConstants;
@@ -603,7 +604,7 @@ public class TermuxTerminalViewClient extends TermuxTerminalViewClientBase {
String text = ShellUtils.getTerminalSessionTranscriptText(session, true, true);
LinkedHashSet<CharSequence> urlSet = DataUtils.extractUrls(text);
LinkedHashSet<CharSequence> urlSet = UrlUtils.extractUrls(text);
if (urlSet.isEmpty()) {
new AlertDialog.Builder(mActivity).setMessage(R.string.title_select_url_none_found).show();
return;

View File

@@ -1,6 +1,6 @@
package com.termux.app;
import com.termux.shared.data.DataUtils;
import com.termux.shared.data.UrlUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -13,7 +13,7 @@ public class TermuxActivityTest {
private void assertUrlsAre(String text, String... urls) {
LinkedHashSet<String> expected = new LinkedHashSet<>();
Collections.addAll(expected, urls);
Assert.assertEquals(expected, DataUtils.extractUrls(text));
Assert.assertEquals(expected, UrlUtils.extractUrls(text));
}
@Test