summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/class_db.cpp9
-rw-r--r--core/os/file_access.cpp55
2 files changed, 59 insertions, 5 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp
index edd49fe95f..b18e3d2b65 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -348,10 +348,11 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
hash = hash_djb2_one_64(mb->get_argument_type(-1), hash); //return
for (int i = 0; i < mb->get_argument_count(); i++) {
- hash = hash_djb2_one_64(mb->get_argument_info(i).type, hash);
- hash = hash_djb2_one_64(mb->get_argument_info(i).name.hash(), hash);
- hash = hash_djb2_one_64(mb->get_argument_info(i).hint, hash);
- hash = hash_djb2_one_64(mb->get_argument_info(i).hint_string.hash(), hash);
+ const PropertyInfo info = mb->get_argument_info(i);
+ hash = hash_djb2_one_64(info.type, hash);
+ hash = hash_djb2_one_64(info.name.hash(), hash);
+ hash = hash_djb2_one_64(info.hint, hash);
+ hash = hash_djb2_one_64(info.hint_string.hash(), hash);
}
hash = hash_djb2_one_64(mb->get_default_argument_count(), hash);
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 7b2062936b..20c1221f2b 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -273,9 +273,62 @@ String FileAccess::get_token() const {
return String::utf8(token.get_data());
}
+class CharBuffer {
+ Vector<char> vector;
+ char stack_buffer[256];
+
+ char *buffer;
+ int capacity;
+ int written;
+
+ bool grow() {
+
+ if (vector.resize(next_power_of_2(1 + written)) != OK) {
+
+ return false;
+ }
+
+ if (buffer == stack_buffer) { // first chunk?
+
+ for (int i = 0; i < written; i++) {
+
+ vector[i] = stack_buffer[i];
+ }
+ }
+
+ buffer = vector.ptrw();
+ capacity = vector.size();
+ ERR_FAIL_COND_V(written >= capacity, false);
+
+ return true;
+ }
+
+public:
+ _FORCE_INLINE_ CharBuffer() :
+ buffer(stack_buffer),
+ capacity(sizeof(stack_buffer) / sizeof(char)),
+ written(0) {
+ }
+
+ _FORCE_INLINE_ void push_back(char c) {
+
+ if (written >= capacity) {
+
+ ERR_FAIL_COND(!grow());
+ }
+
+ buffer[written++] = c;
+ }
+
+ _FORCE_INLINE_ const char *get_data() const {
+
+ return buffer;
+ }
+};
+
String FileAccess::get_line() const {
- CharString line;
+ CharBuffer line;
CharType c = get_8();