Made Vector::ptrw explicit for writing, compiler was sometimes using the wrong function,
leading to unnecesary copy on writes and reduced performance.
This commit is contained in:
parent
7dfba3cda9
commit
bc2e8d99e5
62 changed files with 148 additions and 147 deletions
|
|
@ -585,7 +585,7 @@ size_t NetworkedMultiplayerENet::enet_compress(void *context, const ENetBuffer *
|
|||
if (enet->dst_compressor_mem.size() < req_size) {
|
||||
enet->dst_compressor_mem.resize(req_size);
|
||||
}
|
||||
int ret = Compression::compress(enet->dst_compressor_mem.ptr(), enet->src_compressor_mem.ptr(), ofs, mode);
|
||||
int ret = Compression::compress(enet->dst_compressor_mem.ptrw(), enet->src_compressor_mem.ptr(), ofs, mode);
|
||||
|
||||
if (ret < 0)
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco
|
|||
#endif
|
||||
instance->owner->set_script_instance(instance);
|
||||
|
||||
/* STEP 2, INITIALIZE AND CONSRTUCT */
|
||||
/* STEP 2, INITIALIZE AND CONSRTUCT */
|
||||
|
||||
#ifndef NO_THREADS
|
||||
GDScriptLanguage::singleton->lock->lock();
|
||||
|
|
@ -738,7 +738,7 @@ Error GDScript::load_byte_code(const String &p_path) {
|
|||
Error err = fae->open_and_parse(fa, key, FileAccessEncrypted::MODE_READ);
|
||||
ERR_FAIL_COND_V(err, err);
|
||||
bytecode.resize(fae->get_len());
|
||||
fae->get_buffer(bytecode.ptr(), bytecode.size());
|
||||
fae->get_buffer(bytecode.ptrw(), bytecode.size());
|
||||
memdelete(fae);
|
||||
} else {
|
||||
|
||||
|
|
@ -1324,7 +1324,7 @@ void GDScriptLanguage::_add_global(const StringName &p_name, const Variant &p_va
|
|||
}
|
||||
globals[p_name] = global_array.size();
|
||||
global_array.push_back(p_value);
|
||||
_global_array = global_array.ptr();
|
||||
_global_array = global_array.ptrw();
|
||||
}
|
||||
|
||||
void GDScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@
|
|||
/*************************************************************************/
|
||||
#include "gdscript.h"
|
||||
|
||||
#include "core/engine.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "gdscript_compiler.h"
|
||||
#include "global_constants.h"
|
||||
#include "os/file_access.h"
|
||||
#include "core/engine.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include "editor/editor_file_system.h"
|
||||
|
|
@ -791,7 +791,7 @@ static bool _guess_expression_type(GDScriptCompletionContext &context, const GDS
|
|||
}
|
||||
|
||||
Variant::CallError ce;
|
||||
Variant ret = mb->call(baseptr, argptr.ptr(), argptr.size(), ce);
|
||||
Variant ret = mb->call(baseptr, (const Variant **)argptr.ptr(), argptr.size(), ce);
|
||||
|
||||
if (ce.error == Variant::CallError::CALL_OK && ret.get_type() != Variant::NIL) {
|
||||
|
||||
|
|
@ -1795,7 +1795,7 @@ static void _find_type_arguments(GDScriptCompletionContext &context, const GDScr
|
|||
}
|
||||
|
||||
} else {
|
||||
//regular method
|
||||
//regular method
|
||||
|
||||
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
|
||||
if (p_argidx < m->get_argument_count()) {
|
||||
|
|
|
|||
|
|
@ -1434,7 +1434,7 @@ void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int
|
|||
if (!node->dependencies.empty()) {
|
||||
|
||||
int dc = node->dependencies.size();
|
||||
VisualScriptNodeInstance **deps = node->dependencies.ptr();
|
||||
VisualScriptNodeInstance **deps = node->dependencies.ptrw();
|
||||
|
||||
for (int i = 0; i < dc; i++) {
|
||||
|
||||
|
|
@ -1526,7 +1526,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
|
|||
if (!node->dependencies.empty()) {
|
||||
|
||||
int dc = node->dependencies.size();
|
||||
VisualScriptNodeInstance **deps = node->dependencies.ptr();
|
||||
VisualScriptNodeInstance **deps = node->dependencies.ptrw();
|
||||
|
||||
for (int i = 0; i < dc; i++) {
|
||||
|
||||
|
|
@ -1626,7 +1626,7 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
|
|||
state->flow_stack_pos = flow_stack_pos;
|
||||
state->stack.resize(p_stack_size);
|
||||
state->pass = p_pass;
|
||||
copymem(state->stack.ptr(), p_stack, p_stack_size);
|
||||
copymem(state->stack.ptrw(), p_stack, p_stack_size);
|
||||
//step 2, run away, return directly
|
||||
r_error.error = Variant::CallError::CALL_OK;
|
||||
|
||||
|
|
@ -2277,7 +2277,7 @@ Variant VisualScriptFunctionState::_signal_callback(const Variant **p_args, int
|
|||
|
||||
*working_mem = args; //arguments go to working mem.
|
||||
|
||||
Variant ret = instance->_call_internal(function, stack.ptr(), stack.size(), node, flow_stack_pos, pass, true, r_error);
|
||||
Variant ret = instance->_call_internal(function, stack.ptrw(), stack.size(), node, flow_stack_pos, pass, true, r_error);
|
||||
function = StringName(); //invalidate
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -2319,7 +2319,7 @@ Variant VisualScriptFunctionState::resume(Array p_args) {
|
|||
|
||||
*working_mem = p_args; //arguments go to working mem.
|
||||
|
||||
Variant ret = instance->_call_internal(function, stack.ptr(), stack.size(), node, flow_stack_pos, pass, true, r_error);
|
||||
Variant ret = instance->_call_internal(function, stack.ptrw(), stack.size(), node, flow_stack_pos, pass, true, r_error);
|
||||
function = StringName(); //invalidate
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2466,7 +2466,7 @@ VisualScriptNode::TypeGuess VisualScriptEditor::_guess_output_type(int p_port_ac
|
|||
in_guesses.push_back(g);
|
||||
}
|
||||
|
||||
return node->guess_output_type(in_guesses.ptr(), p_port_action_output);
|
||||
return node->guess_output_type(in_guesses.ptrw(), p_port_action_output);
|
||||
}
|
||||
|
||||
void VisualScriptEditor::_port_action_menu(int p_option) {
|
||||
|
|
|
|||
|
|
@ -1378,7 +1378,7 @@ public:
|
|||
argp[i] = &arr[i];
|
||||
}
|
||||
|
||||
r_ret = Variant::construct(constructor->data_type, argp.ptr(), argp.size(), ce);
|
||||
r_ret = Variant::construct(constructor->data_type, (const Variant **)argp.ptr(), argp.size(), ce);
|
||||
|
||||
if (ce.error != Variant::CallError::CALL_OK) {
|
||||
r_error_str = "Invalid arguments to construct '" + Variant::get_type_name(constructor->data_type) + "'.";
|
||||
|
|
@ -1405,7 +1405,7 @@ public:
|
|||
argp[i] = &arr[i];
|
||||
}
|
||||
|
||||
VisualScriptBuiltinFunc::exec_func(bifunc->func, argp.ptr(), &r_ret, ce, r_error_str);
|
||||
VisualScriptBuiltinFunc::exec_func(bifunc->func, (const Variant **)argp.ptr(), &r_ret, ce, r_error_str);
|
||||
|
||||
if (ce.error != Variant::CallError::CALL_OK) {
|
||||
r_error_str = "Builtin Call Failed. " + r_error_str;
|
||||
|
|
@ -1437,7 +1437,7 @@ public:
|
|||
argp[i] = &arr[i];
|
||||
}
|
||||
|
||||
r_ret = base.call(call->method, argp.ptr(), argp.size(), ce);
|
||||
r_ret = base.call(call->method, (const Variant **)argp.ptr(), argp.size(), ce);
|
||||
|
||||
if (ce.error != Variant::CallError::CALL_OK) {
|
||||
r_error_str = "On call to '" + String(call->method) + "':";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue