summaryrefslogtreecommitdiff
path: root/core/string_db.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/string_db.h
parent988d29bdd8f1d6fc74280cceb76a8b4edb54138d (diff)
parentb47ce5e5d6299533dd8ccafc85d2d2283dd27da6 (diff)
Merge pull request #14744 from poke1024/stringname-compare
Avoid string allocations in AlphCompare
Diffstat (limited to 'core/string_db.h')
-rw-r--r--core/string_db.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/core/string_db.h b/core/string_db.h
index de91e2abd8..9665198ecd 100644
--- a/core/string_db.h
+++ b/core/string_db.h
@@ -138,7 +138,22 @@ public:
_FORCE_INLINE_ bool operator()(const StringName &l, const StringName &r) const {
- return l.operator String() < r.operator String();
+ const char *l_cname = l._data ? l._data->cname : "";
+ const char *r_cname = r._data ? r._data->cname : "";
+
+ if (l_cname) {
+
+ if (r_cname)
+ return is_str_less(l_cname, r_cname);
+ else
+ return is_str_less(l_cname, r._data->name.ptr());
+ } else {
+
+ if (r_cname)
+ return is_str_less(l._data->name.ptr(), r_cname);
+ else
+ return is_str_less(l._data->name.ptr(), r._data->name.ptr());
+ }
}
};