Resource Overhead #536

Closed
opened 2026-01-29 17:38:53 +00:00 by claunia · 1 comment
Owner

Originally created by @Pingger on GitHub (Sep 9, 2022).

The following code does a Integer Division, because:
size is of type int
PageSizeis of type int? and if null or <= 0 is 10 (also int)
so dividing size by PageSize is a Integer Division which is per definition floored!
Casting it to a decimal is useless casting that has performance and memory overhead. Just to then use Math.Floor which changes literally nothing and uses additional performance AND then the code casts it back to an int...

And the worst of all: It makes the code less readable!

c3490ac819/Radzen.Blazor/RadzenPager.razor.cs (L236)

Originally created by @Pingger on GitHub (Sep 9, 2022). The following code does a Integer Division, because: `size` is of type `int` `PageSize`is of type `int?` and if `null` or `<= 0` is `10` (also `int`) so dividing `size` by `PageSize` is a Integer Division which is per definition floored! Casting it to a `decimal` is useless casting that has performance and memory overhead. Just to then use `Math.Floor` which changes literally nothing and uses additional performance AND then the code casts it back to an `int`... And the worst of all: It makes the code less readable! https://github.com/radzenhq/radzen-blazor/blob/c3490ac819024455bd8de8733f20158435c79ad7/Radzen.Blazor/RadzenPager.razor.cs#L236
Author
Owner

@enchev commented on GitHub (Sep 10, 2022):

Hey @Pingger

Not sure what is size, maybe you are referring skip, PageSize is int also not int?. Still, you are right, no idea how this code ended like this - it's fixed now.

@enchev commented on GitHub (Sep 10, 2022): Hey @Pingger Not sure what is size, maybe you are referring skip, PageSize is int also not int?. Still, you are right, no idea how this code ended like this - it's fixed now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#536