MCPcopy Create free account
hub / github.com/apache/arrow / btrim_utf8

Function btrim_utf8

cpp/src/gandiva/precompiled/string_ops.cc:363–384  ·  view source on GitHub ↗

Trims whitespaces from both the ends of the input utf8 sequence

Source from the content-addressed store, hash-verified

361
362// Trims whitespaces from both the ends of the input utf8 sequence
363FORCE_INLINE
364const char* btrim_utf8(gdv_int64 context, const char* data, gdv_int32 data_len,
365 int32_t* out_len) {
366 if (data_len == 0) {
367 *out_len = 0;
368 return "";
369 }
370
371 gdv_int32 start = 0, end = data_len - 1;
372 // start and end denote the first and last positions of non-space
373 // characters in the input string respectively
374 while (start <= end && data[start] == ' ') {
375 ++start;
376 }
377 while (end >= start && data[end] == ' ') {
378 --end;
379 }
380
381 // string has some leading/trailing spaces and some non-space characters
382 *out_len = end - start + 1;
383 return data + start;
384}
385
386// Trims characters present in the trim text from the left end of the base text
387FORCE_INLINE

Callers 1

TESTFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68