LEN_TRIM's folding is currently based on VERIFY(), and it is kind of
slow for the very large CHARACTER arguments that can show up in artificial
test suites. Rewrite in terms of single-character accesses.
Differential Revision: https://reviews.llvm.org/D136901
}
static ConstantSubscript LEN_TRIM(const Character &str) {
- return VERIFY(str, Character{' '}, true);
+ auto j{str.length()};
+ for (; j >= 1; --j) {
+ if (str[j - 1] != ' ') {
+ break;
+ }
+ }
+ return static_cast<ConstantSubscript>(j);
}
static Character REPEAT(const Character &str, ConstantSubscript ncopies) {