Skip to content

Commit

Permalink
little endian optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Quodss committed Jul 31, 2024
1 parent f54e671 commit f04a8bc
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions pkg/noun/jets/c/aor.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,64 @@
#include "jets/w.h"

#include "noun.h"
#include "portable.h"

#if defined(c3_endian) && defined(c3_endian_little) && (c3_endian == c3_endian_little)

u3_noun
u3qc_aor(u3_noun a,
u3_noun b)
{
while ( 1 ) {
if ( c3y == u3r_sing(a, b) ) return c3y;
if ( c3n == u3ud(a) ) {
if ( c3y == u3ud(b) ) return c3n;
if ( c3y == u3r_sing(u3h(a), u3h(b)) ) {
a = u3t(a);
b = u3t(b);
}
else {
a = u3h(a);
b = u3h(b);
}
}
else {
if ( c3n == u3ud(b) ) return c3y;
{
c3_w len_a_y, len_b_y;
c3_y *a_bytes, *b_bytes;
c3_y a_y, b_y;
if ( c3y == u3a_is_cat(a) ) {
len_a_y = 4;
a_bytes = (c3_y*)&a;
}
else {
u3a_atom* a_u = u3a_to_ptr(a);
len_a_y = (a_u->len_w)*4;
a_bytes = (c3_y*)(a_u->buf_w);
}
if ( c3y == u3a_is_cat(b) ) {
len_b_y = 4;
b_bytes = (c3_y*)&b;
}
else {
u3a_atom* b_u = u3a_to_ptr(b);
len_b_y = (b_u->len_w)*4;
b_bytes = (c3_y*)(b_u->buf_w);
}
c3_w len_min = c3_min(len_a_y, len_b_y);
for (c3_w i_y = 0; i_y < len_min; i_y++) {
a_y = a_bytes[i_y];
b_y = b_bytes[i_y];
if ( a_y != b_y ) return __(a_y < b_y);
}
return __(len_a_y < len_b_y);
}
}
}
}

#else

u3_noun
u3qc_aor(u3_noun a,
Expand Down Expand Up @@ -60,6 +117,8 @@
}
}
}

#endif

u3_noun
u3wc_aor(u3_noun cor)
Expand Down

0 comments on commit f04a8bc

Please sign in to comment.