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
true/false inlining can waste chars #39
Comments
About the bug - yeah, it's the same issue as in #38 - I'll probably fix it by avoiding doing const replacement in focus-chars mode if the result is longer than the original tokens (though there are edge cases relating to const vars and to the possibility that even though parts of an expression are longer in constant form, the whole expression is shorter in constant form) About the feature - hmm... So far I never adding tokens as part of minification, and I'm not sure that would be expected, even though --focus-tokens isn't provided. Maybe under some kind of --ignore-tokens option? |
Perfect, focus-chars-only is exactly what I would expect here Oh, An alternate idea might be a new pause/unpause directive; something like: > Do you know other such save-chars-at-the-cost-of-tokens tricks?This was a fun exercise to think through! Here's a few I came up with just now: 1
2any output of my constant companion tool, e.g. replacing 3I just thought up this toy example, probably not useful to you tho: --28 tokens, 55 chars
function f(x) return x*2*3*4*5*6*7 end
a=f(10)
b=f(20) --30 tokens, 33 chars
a=10*2*3*4*5*6*7
b=20*2*3*4*5*6*7 4I suppose the tweetcart standard of using 5similar to 3 but maybe more useful for shrinko8: creating an alias for an often-used variable or constant: |
semi-related to #38
These are both longer (in char-count) than the input:
workaround: compare a builtin symbol instead, since shrinko8 isn't sure whether its a constant or not:
Veering out of bug-report territory and into feature-request territory: shrinko8 could automatically replace "true" and "false" with "0<1" and "1<0", which saves about 2~3 chars each time (since the trailing space can often be removed when merging statements together). I don't know if this idea is in-scope for the tool or not, but it's an interesting idea
The text was updated successfully, but these errors were encountered: