-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Code Cleanup: Improved Performance of MudComponentBase, ResizeObserver, and EventListener #8526
Code Cleanup: Improved Performance of MudComponentBase, ResizeObserver, and EventListener #8526
Conversation
…tBase, ResizeObserver, MudDropZone, and EventManager
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #8526 +/- ##
=======================================
Coverage 89.76% 89.77%
=======================================
Files 411 411
Lines 11824 11830 +6
Branches 2362 2362
=======================================
+ Hits 10614 10620 +6
Misses 682 682
Partials 528 528 ☔ View full report in Codecov by Sentry. |
Hi. |
You bet; I've just resolved the 2 conflicts |
Thanks @jperson2000 |
…r, and EventListener (MudBlazor#8526)
…r, and EventListener (MudBlazor#8526)
Description
This update offers a minor improvement to performance by fixing four instances where
Dictionary<T,U>
lookups were being performed twice, as well as an optimization regarding unnecessary JSON deserialization. Regarding dictionary lookups, consider the following code:... in the above code, the
values
dictionary is being searched twice: once viaContainsKey
then again via the indexer. By refactoring this to useTryGetValue
, we can eliminate the second lookup, like this:The four instances fixed for this PR improve the performance of the following properties and methods:
Additionally, two optimizations were made to
EventListener
:@event
variable was being deserialized from JSON even if no handler existed to utilize itJsonSerializerOptions
was being made for each call when astatic
variable could have been reusedHow Has This Been Tested?
This was tested by running unit tests after changes as well as by visually testing affected components such as testing page resizes, testing all form examples, and testing all MudDropZone examples. The
EventListener
was tested via theMudColorPicker
example.Types of changes
Checklist:
dev
).Notes for Reviewers
I get a
NullReferenceException
when using theMudColorPicker
for the first time because it's attempting to create aMudColor(null)
. I wonder if we can handle this a bit better somehow? (This error existed before this PR; I just noticed it during testing.)