Add trait "iscomplete" to Alphabet
jakobnissen opened this issue · 2 comments
jakobnissen commented
Add trait "iscomplete" to every alphabet. It should default to Val{false}()
. It should return Val{true}
if length(symbols(A)) == 1 << bits_per_symbol(A)
, i.e. if all bitpatterns are valid. In that case, the decoder can skip validation. There are also other efficiencies to be had, such as better random sequence generation.
TransGirlCodes commented
Oooh I like that idea!
jakobnissen commented
Okay, this is now added in #161 . Turns out it was not that important, actually. With a little tweaking of the index functions to remove all unnecessary branches and signed/unsigned conversions, here is what f(x, i) = @inbounds x[i]
compiles to:
julia> @code_native debuginfo=:none f(a, 2)
.section __TEXT,__text,regular,pure_instructions
leaq -4(,%rsi,4), %rax
movq (%rdi), %rcx
movq (%rcx), %rcx
movq %rax, %rdx
shrq $3, %rdx
andq $-8, %rdx
shrxq %rax, (%rcx,%rdx), %rax
andb $15, %al
retq
nopw %cs:(%rax,%rax)
🎉