summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/rendering/shader_preprocessor.cpp16
-rw-r--r--servers/rendering/shader_preprocessor.h4
2 files changed, 8 insertions, 12 deletions
diff --git a/servers/rendering/shader_preprocessor.cpp b/servers/rendering/shader_preprocessor.cpp
index ff1d55f905..0644f5918c 100644
--- a/servers/rendering/shader_preprocessor.cpp
+++ b/servers/rendering/shader_preprocessor.cpp
@@ -54,9 +54,9 @@ int ShaderPreprocessor::Tokenizer::get_index() const {
return index;
}
-void ShaderPreprocessor::Tokenizer::get_and_clear_generated(Vector<ShaderPreprocessor::Token> *r_out) {
- for (int i = 0; i < generated.size(); i++) {
- r_out->push_back(generated[i]);
+void ShaderPreprocessor::Tokenizer::get_and_clear_generated(LocalVector<char32_t> *r_out) {
+ for (uint32_t i = 0; i < generated.size(); i++) {
+ r_out->push_back(generated[i].text);
}
generated.clear();
}
@@ -1206,18 +1206,14 @@ Error ShaderPreprocessor::preprocess(State *p_state, const String &p_code, Strin
break;
}
+ // Add autogenerated tokens if there are any.
+ p_tokenizer.get_and_clear_generated(&output);
+
if (state->disabled) {
// Preprocessor was disabled.
// Read the rest of the file into the output.
output.push_back(t.text);
continue;
- } else {
- // Add autogenerated tokens.
- Vector<Token> generated;
- p_tokenizer.get_and_clear_generated(&generated);
- for (int i = 0; i < generated.size(); i++) {
- output.push_back(generated[i].text);
- }
}
if (t.text == '#') {
diff --git a/servers/rendering/shader_preprocessor.h b/servers/rendering/shader_preprocessor.h
index f198af66f0..406b663228 100644
--- a/servers/rendering/shader_preprocessor.h
+++ b/servers/rendering/shader_preprocessor.h
@@ -83,7 +83,7 @@ private:
int line;
int index;
int size;
- Vector<Token> generated;
+ LocalVector<Token> generated;
private:
void add_generated(const Token &p_t);
@@ -95,7 +95,7 @@ private:
char32_t peek();
int consume_line_continuations(int p_offset);
- void get_and_clear_generated(Vector<Token> *r_out);
+ void get_and_clear_generated(LocalVector<char32_t> *r_out);
void backtrack(char32_t p_what);
LocalVector<Token> advance(char32_t p_what);
void skip_whitespace();