You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Improve usage of String.split() vs get_slice()
This commit is contained in:
@@ -1756,8 +1756,7 @@ void Input::parse_mapping(const String &p_mapping) {
|
||||
void Input::add_joy_mapping(const String &p_mapping, bool p_update_existing) {
|
||||
parse_mapping(p_mapping);
|
||||
if (p_update_existing) {
|
||||
Vector<String> entry = p_mapping.split(",");
|
||||
const String &uid = entry[0];
|
||||
const String uid = p_mapping.get_slicec(',', 0);
|
||||
for (KeyValue<int, Joypad> &E : joy_names) {
|
||||
Joypad &joy = E.value;
|
||||
if (joy.uid == uid) {
|
||||
|
||||
@@ -843,9 +843,8 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins_with_featur
|
||||
for (const KeyValue<String, List<Ref<InputEvent>>> &E : builtins) {
|
||||
String fullname = E.key;
|
||||
|
||||
Vector<String> split = fullname.split(".");
|
||||
const String &name = split[0];
|
||||
String override_for = split.size() > 1 ? split[1] : String();
|
||||
const String &name = fullname.get_slicec('.', 0);
|
||||
String override_for = fullname.get_slice_count(".") > 1 ? fullname.get_slicec('.', 1) : String();
|
||||
|
||||
if (!override_for.is_empty() && OS::get_singleton()->has_feature(override_for)) {
|
||||
builtins_with_overrides[name].push_back(override_for);
|
||||
@@ -855,9 +854,8 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins_with_featur
|
||||
for (const KeyValue<String, List<Ref<InputEvent>>> &E : builtins) {
|
||||
String fullname = E.key;
|
||||
|
||||
Vector<String> split = fullname.split(".");
|
||||
const String &name = split[0];
|
||||
String override_for = split.size() > 1 ? split[1] : String();
|
||||
const String &name = fullname.get_slicec('.', 0);
|
||||
String override_for = fullname.get_slice_count(".") > 1 ? fullname.get_slicec('.', 1) : String();
|
||||
|
||||
if (builtins_with_overrides.has(name) && override_for.is_empty()) {
|
||||
// Builtin has an override but this particular one is not an override, so skip.
|
||||
|
||||
Reference in New Issue
Block a user