Conversation
Contributor
|
Can't we apply this optimization to |
Contributor
|
Something like this in lib/elixir/src/elixir_erl_for.erl: %% Add before the generic build_into/7 clause.
build_into(Ann, Clauses, Expr, {bin, _, _} = Into, Uniq, InitVars, S) ->
{Prefix, SP} = build_var(Ann, S),
{Tail, ST} = build_inline(
Ann, Clauses, Expr, {bin, Ann, []}, Uniq, InitVars, SP
),
Result = {bin, Ann, [
{bin_element, Ann, Prefix, default, [bitstring]},
{bin_element, Ann, Tail, default, [bitstring]}
]},
{{block, Ann, [
{match, Ann, Prefix, Into},
Result
]}, ST}; |
Member
|
Let’s try optimizing the compiler first, yeah, then we can revisit this! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Assisted-by: GPT-5.6
This avoids collector and per-byte binary allocations (
into: <<first_byte>>invokes Collectable.BitString,compiler only enables the native bitstring-comprehension path for
into: <<>>).New implementation scales approximately linearly with the number of output elements, with a nearly constant per-element cost.
Im not completely sure whether this is needed, or maybe compiler should be improved instead...
Bench