Skip to content

Caching project settings variables #304

@TheYellowArchitect

Description

@TheYellowArchitect

🐛 Description

ProjectSettings.get_setting boils down to a Node.get call under the hood, so I'd say it's fine as it is. But if you want to be proactive about perf, feel free to introduce a variable with an underscore prefix that's initialized in _ready and use that.

According to the above, all invocations of ProjectSettings.get() call Node.get() which I assume is a property getter (via string!)
ProjectSettings.get_setting is invoked at least 5 times per tick in RollbackSynchronizer so as the quote says, all of these project settings which are read-only should be cached.

Example code below for reference of current project settings implementation

## How many ticks to store as history.
##
## The larger the history limit, the further we can roll back into the past, 
## thus the more latency we can manage.
##
## [i]read-only[/i], you can change this in the project settings
var history_limit: int:
	get:
		return ProjectSettings.get_setting("netfox/rollback/history_limit", 64)
	set(v):
		push_error("Trying to set read-only variable history_limit")

and from what I understand should be done (correct me if I'm wrong)

var _history_limit: int
## How many ticks to store as history.
##
## The larger the history limit, the further we can roll back into the past, 
## thus the more latency we can manage.
##
## [i]read-only[/i], you can change this in the project settings
var history_limit: int:
	get:
		return _history_limit
	set(v):
		push_error("Trying to set read-only variable history_limit")

...

func _ready():
      _history_limit = 64

So probably a function at _ready() is required to be added, which sets all starting values for the project setting variables.

Btw, I suggest first doing a search in godotengine if it plans to cache the project settings variables, so we don't implement it here and have it be needless by godot in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions