Skip to content
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

Batch atob() conversion #41

Open
claybiockiller opened this issue Jan 7, 2023 · 1 comment
Open

Batch atob() conversion #41

claybiockiller opened this issue Jan 7, 2023 · 1 comment

Comments

@claybiockiller
Copy link

claybiockiller commented Jan 7, 2023

Currently, there is only 1 triplet has batch atob() definition: "mCh" == atob("bUNo"). But there are more triplets which batch atob() definition are practical:
"#!/" (common in URL hashbang grammar) currently costs 1989 chars, while atob("IyEv") only costs 1942 chars;
"{b:" (sometimes can be seen in object definitions) currently costs 1121 chars, while atob("e2I6") only costs 961 chars;
"www" (well-known part of ___domain name) currently costs 990 chars, while atob("d3d3") only costs 900 chars.
But batch atob() can go further since string segment made up by triplets mentioned before can be created by only one atob(), which is shorter by three-by-three conversion. additionally, some triplets are impractical with atob() as triplet, but their corresponding base64 string have code shorter than original triplet, hence can be combined into single atob() with suitable context. For example, "://" (common in URL header) currently costs 1311 chars, which base64 string "Oi8v" only costs 723 chars, but atob("Oi8v") costs 1544 chars.
Such usage of batch atob() conversion would be challenging since you need an algorithm to clip out most suitable segment form original string for batch atob() conversion.

@fasttime
Copy link
Owner

fasttime commented Jan 8, 2023

"mCh" is useful to optimize "fromCharCode" which is found in many definitions. Providing definitions for every sequence of characters that could be possibly optimized with atob is not an option. I started working on a generic algorithm to optimize arbitrary sequences using different native functions, but in order to implement this feature, many parts of JScrewIt need to be rewritten, so I am thinking to do this in a next major version, without support for certain old engines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants