Skip to content

Commit 4e3b967

Browse files
authored
[improvement](constant folding) Reuse parsed URL query bounds (#68177)
Related PR: #68011 Problem Summary: The FE constant-folding implementation of `parse_url(..., 'QUERY')` already locates the first `#` in the URL, but then creates a suffix string and scans that suffix for `#` again. This repeats work and, when a fragment exists, temporarily copies the fragment even though its end position is already known. Reuse the existing query and fragment boundaries to extract the result directly. The returned values and NULL/empty-string behavior are unchanged. ### Release note None ### Check List (For Author) - Test: No need to test (small allocation and scan reduction; no behavior change) - Behavior changed: No - Does this need documentation: No
1 parent 1f41d42 commit 4e3b967

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable

‎fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/StringArithmetic.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,8 @@ private static String parseUrlQuery(String protocolEnd) {
10441044
// fragment and the url has no query component.
10451045
return null;
10461046
}
1047-
String queryStart = protocolEnd.substring(startPos + 1);
1048-
return substringEnd(queryStart, queryStart.indexOf('#'));
1047+
return protocolEnd.substring(startPos + 1,
1048+
fragmentPos >= 0 ? fragmentPos : protocolEnd.length());
10491049
}
10501050

10511051
private static String parseUrlRef(String protocolEnd) {

0 commit comments

Comments
 (0)