imay commented on a change in pull request #1451: Add string function split_part
URL: https://github.com/apache/incubator-doris/pull/1451#discussion_r301613106
 
 

 ##########
 File path: be/src/exprs/string_functions.cpp
 ##########
 @@ -761,4 +761,63 @@ StringVal StringFunctions::money_format(FunctionContext 
*context, const LargeInt
     return do_money_format(context, ss.str());
 }
 
+static int index_of(const uint8_t* source, int sourceOffset, int sourceCount,
+                const uint8_t* target, int targetOffset, int targetCount,
+                int fromIndex) {
+    if (fromIndex >= sourceCount) {
+        return (targetCount == 0 ? sourceCount : -1);
+    }
+    if (fromIndex < 0) {
+        fromIndex = 0;
+    }
+    if (targetCount == 0) {
+        return fromIndex;
+    }
+    const uint8_t first = target[targetOffset];
+    int max = sourceOffset + (sourceCount - targetCount);
+    for (int i = sourceOffset + fromIndex; i <= max; i++) {
+        if (source[i] != first) { // Look for first character
+            while (++i <= max && source[i] != first);
+        }
 
 Review comment:
   you can merge if while to a while ?
   ```suggestion
           while (i <= max && source[i] != first) i++;
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to