Last active
June 10, 2017 20:49
-
-
Save alex-ilin/aac4f5b40c214ec96f4fe12a8caeea5e to your computer and use it in GitHub Desktop.
Greater memory footprint due to `keys` and `map`
This file contains 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
: first-column-width ( table model -- width ) | |
value>> dup sequence? [ | |
length 1 - 1array | |
] [ | |
make-mirror keys | |
] if [ unparse-short ] map | |
over renderer>> column-titles first suffix | |
row-column-widths supremum ; | |
: <inspector-table> ( model -- table ) | |
[ | |
[ make-slot-descriptions ] <arrow> inspector-renderer <table> | |
[ invoke-primary-operation ] >>action | |
line-color >>column-line-color | |
6 >>gap | |
15 >>min-rows | |
15 >>max-rows | |
40 >>min-cols | |
40 >>max-cols | |
monospace-font >>font | |
dup | |
] keep first-column-width 0 2array >>fixed-column-widths ; |
The proposed code would not work, because column-titles first
returns the string "Key". I'd have to call cell-dim nip +
on the string to be able to max
it with the result of row-column-widths supremum
. But calling cell-dim
that way is what I'm trying to avoid by using the row-column-widths
in the first place.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could also do something like this to avoid that last
first suffix
, although I don't think it's a big deal.