Skip to content

refactor: Statically typed almost everything#420

Merged
elementbound merged 6 commits intofoxssake:mainfrom
gk98s:main
Mar 5, 2025
Merged

refactor: Statically typed almost everything#420
elementbound merged 6 commits intofoxssake:mainfrom
gk98s:main

Conversation

@gk98s
Copy link
Copy Markdown
Contributor

@gk98s gk98s commented Feb 25, 2025

Swapped Strings to StringNames where possible(StringNames are much faster), statically typed functions and variables that weren't already statically typed for improved performance.

_state_to = _PropertySnapshot.new()

for property in properties:
for property: String in properties:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gk98s fyi this breaks in Godot 4.1 which is supported by netfox

# Calculate rtt bounds
var rtt_min = sorted_samples.front().get_rtt()
var rtt_max = sorted_samples.back().get_rtt()
var rtt_min: Variant = sorted_samples.front().get_rtt()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typing these as variants does not add much extra info - in these cases it's better to cast them to their known types.

return

var sample = _awaiting_samples[idx] as NetworkClockSample
var sample: NetworkClockSample = _awaiting_samples[idx] as NetworkClockSample
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just use :=, since the value is already cast to the right type


func make_patch(data: _PropertySnapshot) -> _PropertySnapshot:
var result: Dictionary = {}
var result := {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

@elementbound elementbound merged commit 7e7f87a into foxssake:main Mar 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants