summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2020-05-13 05:19:29 -0400
committerAaron Franke <arnfranke@yahoo.com>2020-06-03 00:03:34 -0400
commite5ae89775a375106eaad93e2fd1607748c0fa005 (patch)
tree6f875513c5cf0c7c20fcd1ecc823f0047cc74071 /core
parentbb8aa107fd064a095479350bd22b1ce3ed146784 (diff)
downloadredot-engine-e5ae89775a375106eaad93e2fd1607748c0fa005.tar.gz
Remove 32-bit String hex_to_int method
Diffstat (limited to 'core')
-rw-r--r--core/ustring.cpp46
-rw-r--r--core/ustring.h3
2 files changed, 3 insertions, 46 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 986bf089c8..698187cc29 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -1618,49 +1618,7 @@ String::String(const StrRange &p_range) {
copy_from(p_range.c_str, p_range.len);
}
-int String::hex_to_int(bool p_with_prefix) const {
- if (p_with_prefix && length() < 3) {
- return 0;
- }
-
- const CharType *s = ptr();
-
- int sign = s[0] == '-' ? -1 : 1;
-
- if (sign < 0) {
- s++;
- }
-
- if (p_with_prefix) {
- if (s[0] != '0' || s[1] != 'x') {
- return 0;
- }
- s += 2;
- }
-
- int hex = 0;
-
- while (*s) {
- CharType c = LOWERCASE(*s);
- int n;
- if (c >= '0' && c <= '9') {
- n = c - '0';
- } else if (c >= 'a' && c <= 'f') {
- n = (c - 'a') + 10;
- } else {
- return 0;
- }
-
- ERR_FAIL_COND_V_MSG(hex > INT32_MAX / 16, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + *this + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
- hex *= 16;
- hex += n;
- s++;
- }
-
- return hex * sign;
-}
-
-int64_t String::hex_to_int64(bool p_with_prefix) const {
+int64_t String::hex_to_int(bool p_with_prefix) const {
if (p_with_prefix && length() < 3) {
return 0;
}
@@ -3813,7 +3771,7 @@ bool String::is_valid_ip_address() const {
continue;
}
if (n.is_valid_hex_number(false)) {
- int nint = n.hex_to_int(false);
+ int64_t nint = n.hex_to_int(false);
if (nint < 0 || nint > 0xffff) {
return false;
}
diff --git a/core/ustring.h b/core/ustring.h
index f82e31f995..c48bca5552 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -245,9 +245,8 @@ public:
bool is_numeric() const;
double to_double() const;
float to_float() const;
- int hex_to_int(bool p_with_prefix = true) const;
- int64_t hex_to_int64(bool p_with_prefix = true) const;
+ int64_t hex_to_int(bool p_with_prefix = true) const;
int64_t bin_to_int64(bool p_with_prefix = true) const;
int64_t to_int() const;
static int to_int(const char *p_str, int p_len = -1);