@@ -33,7 +33,9 @@ function DecoratorSize:new(opts)
33
33
o .column_width = opts .renderer .size .column_width
34
34
o .show_folder_size = opts .renderer .size .show_folder_size
35
35
o .units = { " B" , " KB" , " MB" , " GB" , " TB" , " PB" , " EB" , " ZB" , " YB" }
36
- o .format_unit = opts .renderer .size .format_unit -- guaranteed to be a function
36
+
37
+ -- Guaranteed to be a function from previous setup
38
+ o .format_unit = opts .renderer .size .format_unit
37
39
o .format_size = function (size )
38
40
local formatted = string
39
41
.format (" %.2f" , size )
51
53
--- @private
52
54
--- @param size number size in bytes
53
55
--- @return string
54
- --- edit: Since then I've moved a lot of ifs around getting down to only three, but I'll keep the comment just in case.
56
+ --- edit: Since then I've moved a lot of ifs around getting down to only three, but I'll keep the comment bellow just in case.
55
57
--- NOTE: This function still try it's best to minified the string
56
- --- generated, but this implies that we have more than 3 branchs
58
+ --- generated, but this implies that we have some branches
57
59
--- to determined how much bytes can we shave from the string to
58
- --- comply to self.column_width. Since we know self.column_width doesn't
59
- --- change, a better way could be to decide a version of 'human_readable_size' based
60
- --- on self.column_width once at this object's construction.
61
- --- Basically, instead of this method, we would baking all ifs first to decide which function to bind to possible field `self.human_readable_size`
62
- --- I don't actually know if it would be faster without test.
60
+ --- comply to `self.column_width`.
61
+ --- Since we know `self.column_width` doesn't change, a better way could be
62
+ --- decide a version of 'human_readable_size' a priori, based
63
+ --- on `self.column_width` *once* at this object's construction.
64
+ --- Basically, instead of this method, we would "baking" all ifs first
65
+ --- to decide which function to bind to possible field `self.human_readable_size`.
63
66
function DecoratorSize :human_readable_size (size )
64
67
-- Check for nan, negative, etc.
65
68
if type (size ) ~= " number" or size ~= size or size < 0 then
0 commit comments