refactor: signal instead of busy-wait, debug call stack, immutable const bindings, string interpolation, linter fixes#40
Open
itsrenderman wants to merge 1 commit into
Conversation
…nst bindings, string interpolation, linter fixes
Contributor
Author
|
Just a few changes I thought might be cool to include in Overture. Lmk! 😄 |
Owner
|
That's an awesome group of changes! I'm still going to test performance and check for edge cases, but just a quick aside: Moonwave was crashing when processing a file containing |
Contributor
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Library Loading
This eliminates the need to defer library loading.
BindableEvents.This allows for faster retrieval of signals to indicate to
LoadLibrarycalls that the module is loaded, as we do not need to iterate over the whole cache.Debugging
Replace busy-wait "infinite yield" warnings with
BindableEventsignalsEliminates need to loop over the cache table every second which (especially during start-up) could cause performance degredation.
Also eliminates need to delay cache removal by 1 second which (I believe) was previously done for debug logging purposes.
Allows the "Debug" attribute to be changed during runtime and accordingly reflect onto newly loaded libraries.
(I assume we do not want to rely on packages such as
sleitnick/signal, to maintain a simple installation process without requiring Wally, henceBindableEvents)Print the current function call stack to console when "infinite yield" warnings are logged.
YouTube: Example of call stack logging
This message has been constructed to resemble the default studio infinite yield warning message.
Unfortunately the blue info text can currently only be achieved via
TestService, though Engine API release 717 suggests we may be able to useLogService:Infoin the future.Immutable Constant Bindings
localvariable assignments toconstbinding declarations wherever appropriate.This newly available Luau declaration is great at informing code maintainers and readers that the variable is not going to be re-assigned during runtime.
This declaration can also prevent unintented consequences of variable re-assignment, where perhaps specific parts of the code may not be expecting a variable to change.
Miscellaenous
Use string interpolation over
string.format.String interpolation is generally favored nowadays over
string.formatfor any interpolation that doesn't require formatting specifiers or flags, usually for number representation.Function return types.
Some methods didn't include their return type, but still opted to document it for Moonwave.
All functions now properly indicate their return type, which is automatically detected by Moonwave.
Linter fixes.
The formatting now adheres to the default customs set out by selene and luau-lsp.
The defaults may not be favored by everyone, but following them does improve readability and (importantly) consistency.