Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nodes being renamed into garbage upon conflict #54987

Merged
merged 1 commit into from
Jan 4, 2022

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Nov 15, 2021

Fresh new regression from #54072
D0zRII1TR9
(well maybe they aren't fresh anymore at this point)

@KoBeWi KoBeWi added this to the 4.0 milestone Nov 15, 2021
@KoBeWi KoBeWi requested a review from a team as a code owner November 15, 2021 01:07
akien-mga
akien-mga previously approved these changes Nov 15, 2021
@akien-mga
Copy link
Member

Actually taking back my approval, changing Node::set_name defeats the whole purpose of having this be optional, no? This will mean that at runtime, costly human readable name conflict resolution will be performed.

@KoBeWi
Copy link
Member Author

KoBeWi commented Nov 15, 2021

I checked the set_name() usages and they are mostly used for TabContainer tabs, the add_child() method itself doesn't use it. Node only internally uses it inside duplicate() and the most heavy usage I found is the instantiate() method.

set_name() is a setter, so not sure if it can have an optional argument. I could add set_name_nocheck() if performance is a concern.

@akien-mga
Copy link
Member

I checked the set_name() usages and they are mostly used for TabContainer tabs, the add_child() method itself doesn't use it. Node only internally uses it inside duplicate() and the most heavy usage I found is the instantiate() method.

That's for the editor usage, but users can't set Node names from script and could write egregiously slow code like #54177 with e.g.:

func _ready():
	for i in range(40000):
		var node = Node.new()
		node.name = "MyNode"
		add_child(node)

But let's see what @godotengine/core folks think about it.

@KoBeWi
Copy link
Member Author

KoBeWi commented Nov 15, 2021

Well my thinking is that if you use set_name(), you most likely want the name to be human-readable.

func _ready():
	for i in range(40000):
		var node = Node.new()
		add_child(node)

wouldn't have performance concerns.

@reduz
Copy link
Member

reduz commented Jan 4, 2022

@KoBeWi's reasoning makes sense to me, if you use set_name you most definitely want a human readable conflict resolution.

@akien-mga akien-mga merged commit 23342ac into godotengine:master Jan 4, 2022
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the @@Node2D@@69@@420@@@ branch January 4, 2022 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants