summaryrefslogtreecommitdiffstats
path: root/core/ustring.h
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-12-27 15:44:45 -0300
committerGitHub <noreply@github.com>2017-12-27 15:44:45 -0300
commita663dbfdd8465d45a03e4880c0d907334236b260 (patch)
tree3bd3c01a2697b8892e10fe28e8dac8f035d1e8e8 /core/ustring.h
parent988d29bdd8f1d6fc74280cceb76a8b4edb54138d (diff)
parentb47ce5e5d6299533dd8ccafc85d2d2283dd27da6 (diff)
downloadredot-engine-a663dbfdd8465d45a03e4880c0d907334236b260.tar.gz
Merge pull request #14744 from poke1024/stringname-compare
Avoid string allocations in AlphCompare
Diffstat (limited to 'core/ustring.h')
-rw-r--r--core/ustring.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/core/ustring.h b/core/ustring.h
index 73537bfd13..1bb4719b85 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -279,6 +279,29 @@ struct NaturalNoCaseComparator {
}
};
+template <typename L, typename R>
+_FORCE_INLINE_ bool is_str_less(const L *l_ptr, const R *r_ptr) {
+
+ while (true) {
+
+ if (*l_ptr == 0 && *r_ptr == 0)
+ return false;
+ else if (*l_ptr == 0)
+ return true;
+ else if (*r_ptr == 0)
+ return false;
+ else if (*l_ptr < *r_ptr)
+ return true;
+ else if (*l_ptr > *r_ptr)
+ return false;
+
+ l_ptr++;
+ r_ptr++;
+ }
+
+ CRASH_COND(true); // unreachable
+}
+
/* end of namespace */
//tool translate