github-actions[bot] commented on code in PR #13914:
URL: https://github.com/apache/doris/pull/13914#discussion_r1042435020
##########
be/src/exprs/string_functions.cpp:
##########
@@ -920,35 +920,94 @@
return -1;
}
+static int last_index_of(const uint8_t* source, int source_len, const uint8_t*
target,
+ int target_len, int to_index) {
+ if (to_index < 0) {
+ return -1;
+ }
+ if (to_index >= source_len) {
+ to_index = source_len - 1;
+ }
+ if (target_len == 0) {
+ return to_index;
+ }
+ const uint8_t last = target[target_len - 1];
+ int min = target_len;
+ for (int i = to_index; i >= min; i--) {
+ while (i >= min && source[i] != last) i--; // Look for last character
+ if (i >= min) { // Found first character, now look at the rest of v2
+ int j = i - 1;
+ int end = j - target_len + 1;
+ for (int k = target_len - 2; j > end && source[j] == target[k];
j--, k--)
+ ;
+ if (j == end) {
Review Comment:
warning: statement should be inside braces
[readability-braces-around-statements]
```suggestion
-, k--) {
;
}
```
##########
be/src/exprs/string_functions.cpp:
##########
@@ -920,35 +920,94 @@ static int index_of(const uint8_t* source, int
source_offset, int source_count,
return -1;
}
+static int last_index_of(const uint8_t* source, int source_len, const uint8_t*
target,
+ int target_len, int to_index) {
+ if (to_index < 0) {
+ return -1;
+ }
+ if (to_index >= source_len) {
+ to_index = source_len - 1;
+ }
+ if (target_len == 0) {
+ return to_index;
+ }
+ const uint8_t last = target[target_len - 1];
+ int min = target_len;
+ for (int i = to_index; i >= min; i--) {
+ while (i >= min && source[i] != last) i--; // Look for last character
+ if (i >= min) { // Found first character, now look at the rest of v2
Review Comment:
warning: statement should be inside braces
[readability-braces-around-statements]
```suggestion
i--) {
aracter {
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]