Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 00380076 authored by Kiran Ramachandra's avatar Kiran Ramachandra
Browse files

Optimized scheme sanitization performance by replacing regex operation with string replacement

The `replaceAll` method utilizes regular expressions, which can incur a performance cost due to the parsing required. In this modified code, uses `replace` method instead. This change often leads to faster execution, as in many cases the replacement is unnecessary. When it is needed, replace operates in a more straightforward, linear fashion, avoiding the overhead associated with regular expressions.

Bug: 261721900
Bug: 341043283
Test: atest FrameworksCoreTests:android.net.UriTest

Change-Id: I02e6f225db36324d89b66db02c755822cfb29bc9
parent 60bd06f1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1388,7 +1388,7 @@ public abstract class Uri implements Parcelable, Comparable<Uri> {
         */
        public Builder scheme(String scheme) {
            if (scheme != null) {
                this.scheme = scheme.replaceAll("://", "");
                this.scheme = scheme.replace("://", "");
            } else {
                this.scheme = null;
            }