From f04a8bcfdf02f5e735b39155d163cff1e9272d84 Mon Sep 17 00:00:00 2001 From: Quodss Date: Wed, 31 Jul 2024 20:30:01 +0200 Subject: [PATCH] little endian optimization --- pkg/noun/jets/c/aor.c | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/pkg/noun/jets/c/aor.c b/pkg/noun/jets/c/aor.c index 9125ea2e85..5d6b705879 100644 --- a/pkg/noun/jets/c/aor.c +++ b/pkg/noun/jets/c/aor.c @@ -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, @@ -60,6 +117,8 @@ } } } + +#endif u3_noun u3wc_aor(u3_noun cor)