Skip to content

Commit e3f834f

Browse files
committed
Small improvement of FX.25 RS encoder speed
The old design walked the entire feedback array XORing all values, then shifted them all down by one index. This design does the shift-by-one while doing the XOR work to save a step. Signed-off-by: Justin Brzozoski <justin.brzozoski@gmail.com>
1 parent 5fd8120 commit e3f834f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: src/fx25_encode.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ void ENCODE_RS(struct rs * restrict rs, DTYPE * restrict data, DTYPE * restrict
6969
for(i=0;i<NN-NROOTS;i++){
7070
feedback = INDEX_OF[data[i] ^ bb[0]];
7171
if(feedback != A0){ /* feedback term is non-zero */
72+
/* Shift and XOR */
7273
for(j=1;j<NROOTS;j++)
73-
bb[j] ^= ALPHA_TO[MODNN(feedback + GENPOLY[NROOTS-j])];
74-
}
75-
/* Shift */
76-
memmove(&bb[0],&bb[1],sizeof(DTYPE)*(NROOTS-1));
77-
if(feedback != A0)
74+
bb[j-1] = bb[j] ^ ALPHA_TO[MODNN(feedback + GENPOLY[NROOTS-j])];
7875
bb[NROOTS-1] = ALPHA_TO[MODNN(feedback + GENPOLY[0])];
79-
else
76+
} else{
77+
/* Shift only */
78+
memmove(&bb[0],&bb[1],sizeof(DTYPE)*(NROOTS-1));
8079
bb[NROOTS-1] = 0;
80+
}
8181
}
8282
}
8383

0 commit comments

Comments
 (0)