leptris 1.9.222.2-x86_64-linux → 1.9.222.3-x86_64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a2572ad1d071c50c78534599f7fd5085eb10440ee977adfcde86fdeb54124e5
4
- data.tar.gz: 8de31d649e8716712d6b323d5424cb95963a8360fad615a401da1b607fa6d993
3
+ metadata.gz: c559bcf319459f78dc97a3d2c758e0465c2c0d21dc02b69a4f379661462b40d4
4
+ data.tar.gz: bce492a2a2d6de48566c781031826039fa897ac01ec689d55cee6ca63fb473c9
5
5
  SHA512:
6
- metadata.gz: '0209e0b311b3811bea6948f8d36dfa0053b63efd117fe76b3eb471c3182dca8acead4de51a679a7273900ebd8ed3a0c81189abe3849c2896b9885ecba12c6aea'
7
- data.tar.gz: 61ae26f2a6e027e7cb2eec1326a24b1f722e158ead86db7496f6e27f28cdb1e7083105906e418f358ba04a4c13e07b154b872c2ac7f1055cb7087e36c220cb25
6
+ metadata.gz: '019ca5f276d428d6ad5c043cc9fdcacf566cc7f67cd33a795af6f5d2045e45bf305badc2878833293475b164c7b7598a7206aa30cd41b65d4f8fabd5bd67979c'
7
+ data.tar.gz: 7191eb516af67747c5e2a9b634e4d625e8dfeec70ad264e02b2870d4d36beb0e64c2ecdb4773e16859eac488ded5cbcd23aff359208d206412c104616c8a5d1f
@@ -135,6 +135,9 @@ static VALUE c_iteration_scope;
135
135
  static VALUE c_leptris_error;
136
136
  static VALUE c_b_document, c_b_freed, c_ffi_pointer;
137
137
  static ID id_ptr_new, id_freed_new, id_alive;
138
+ static ID id_iv_c_address, id_iv_document, id_iv_parent;
139
+ static ID id_iv_structure_memoizable, id_iv_native_fast;
140
+ static ID id_iv_pub_document, id_iv_addr_reads_fast, id_iv_node_type;
138
141
  static void check_status_c(int st);
139
142
 
140
143
  #define NT_ELEMENT 0
@@ -839,8 +842,38 @@ struct trav_state {
839
842
  VALUE err;
840
843
  void *self_ptr;
841
844
  int for_visit;
845
+ /* Hoisted per-walk state (was re-resolved per node): the
846
+ * document's wrapper cache and the iteration-scope class
847
+ * check. #312 item 1. */
848
+ VALUE cache;
849
+ VALUE klass_memo_flag;
842
850
  };
843
851
 
852
+ /* Construct-or-fetch the binding wrapper for node_ptr against the
853
+ * per-walk hoisted cache (#312 item 1): static-ID ivar writes (no
854
+ * per-call string interning), the scope class check precomputed. */
855
+ static VALUE trav_wrapper_for(struct trav_state *st, void *node_ptr,
856
+ int kind)
857
+ {
858
+ VALUE key = ULL2NUM((uint64_t)(uintptr_t)node_ptr);
859
+ VALUE node = rb_hash_aref(st->cache, key);
860
+ if (!NIL_P(node)) return node;
861
+
862
+ node = rb_obj_alloc(binding_klass_for(kind));
863
+ rb_ivar_set(node, id_iv_c_address, key);
864
+ rb_ivar_set(node, id_iv_document, st->document);
865
+ rb_ivar_set(node, id_iv_parent, Qnil);
866
+ VALUE fast = st->klass_memo_flag;
867
+ rb_ivar_set(node, id_iv_structure_memoizable, fast);
868
+ rb_ivar_set(node, id_iv_native_fast, fast);
869
+ rb_ivar_set(node, id_iv_pub_document,
870
+ fast == Qtrue ? st->document : Qnil);
871
+ rb_ivar_set(node, id_iv_addr_reads_fast, Qtrue);
872
+ rb_ivar_set(node, id_iv_node_type, INT2FIX(kind));
873
+ rb_hash_aset(st->cache, key, node);
874
+ return node;
875
+ }
876
+
844
877
  static VALUE trav_yield_one(VALUE arg)
845
878
  {
846
879
  return rb_yield(arg);
@@ -849,33 +882,13 @@ static VALUE trav_yield_one(VALUE arg)
849
882
  static int trav_cb(void *node_ptr, void *user)
850
883
  {
851
884
  struct trav_state *st = user;
852
- VALUE cache, key, node;
885
+ VALUE node;
853
886
  int kind, state;
854
887
 
855
888
  if (st->err != Qnil)
856
889
  return 1;
857
890
  kind = f_node_type(node_ptr);
858
- cache = binding_cache_of(st->document);
859
- key = ULL2NUM((uint64_t)(uintptr_t)node_ptr);
860
- node = rb_hash_aref(cache, key);
861
- if (NIL_P(node)) {
862
- node = rb_obj_alloc(binding_klass_for(kind));
863
- rb_iv_set(node, "@c_address", key);
864
- rb_iv_set(node, "@document", st->document);
865
- rb_iv_set(node, "@parent", Qnil);
866
- if (rb_obj_class(st->document) == c_iteration_scope) {
867
- rb_iv_set(node, "@structure_memoizable", Qfalse);
868
- rb_iv_set(node, "@native_fast", Qfalse);
869
- rb_iv_set(node, "@pub_document", Qnil);
870
- } else {
871
- rb_iv_set(node, "@structure_memoizable", Qtrue);
872
- rb_iv_set(node, "@native_fast", Qtrue);
873
- rb_iv_set(node, "@pub_document", st->document);
874
- }
875
- rb_iv_set(node, "@addr_reads_fast", Qtrue);
876
- rb_iv_set(node, "@node_type", INT2FIX(kind));
877
- rb_hash_aset(cache, key, node);
878
- }
891
+ node = trav_wrapper_for(st, node_ptr, kind);
879
892
  rb_protect(trav_yield_one, node, &state);
880
893
  if (state) {
881
894
  st->err = rb_errinfo();
@@ -894,6 +907,9 @@ static VALUE nf_traverse_binding(VALUE self, VALUE document,
894
907
  st.document = document;
895
908
  st.err = Qnil;
896
909
  st.self_ptr = (void *)(uintptr_t)NUM2ULL(addr);
910
+ st.cache = binding_cache_of(document);
911
+ st.klass_memo_flag =
912
+ rb_obj_class(document) == c_iteration_scope ? Qfalse : Qtrue;
897
913
  st.for_visit = 0;
898
914
  f_node_traverse(st.self_ptr, 1 /* TRAVERSE_POST_ORDER */,
899
915
  trav_cb, &st);
@@ -922,33 +938,13 @@ static void visit_cb(void *user, void *node_ptr, int entering,
922
938
  * happens after the walk, same observable outcome. */
923
939
  struct trav_state *st = user;
924
940
  struct visit_yield_args va;
925
- VALUE cache, key, node;
941
+ VALUE node;
926
942
  int kind, state;
927
943
 
928
944
  if (st->err != Qnil)
929
945
  return;
930
946
  kind = f_node_type(node_ptr);
931
- cache = binding_cache_of(st->document);
932
- key = ULL2NUM((uint64_t)(uintptr_t)node_ptr);
933
- node = rb_hash_aref(cache, key);
934
- if (NIL_P(node)) {
935
- node = rb_obj_alloc(binding_klass_for(kind));
936
- rb_iv_set(node, "@c_address", key);
937
- rb_iv_set(node, "@document", st->document);
938
- rb_iv_set(node, "@parent", Qnil);
939
- if (rb_obj_class(st->document) == c_iteration_scope) {
940
- rb_iv_set(node, "@structure_memoizable", Qfalse);
941
- rb_iv_set(node, "@native_fast", Qfalse);
942
- rb_iv_set(node, "@pub_document", Qnil);
943
- } else {
944
- rb_iv_set(node, "@structure_memoizable", Qtrue);
945
- rb_iv_set(node, "@native_fast", Qtrue);
946
- rb_iv_set(node, "@pub_document", st->document);
947
- }
948
- rb_iv_set(node, "@addr_reads_fast", Qtrue);
949
- rb_iv_set(node, "@node_type", INT2FIX(kind));
950
- rb_hash_aset(cache, key, node);
951
- }
947
+ node = trav_wrapper_for(st, node_ptr, kind);
952
948
  va.node = node;
953
949
  va.entering = entering ? Qtrue : Qfalse;
954
950
  va.depth = INT2NUM(depth);
@@ -966,6 +962,9 @@ static VALUE nf_visit_binding(VALUE self, VALUE document, VALUE addr)
966
962
  st.document = document;
967
963
  st.err = Qnil;
968
964
  st.self_ptr = (void *)(uintptr_t)NUM2ULL(addr);
965
+ st.cache = binding_cache_of(document);
966
+ st.klass_memo_flag =
967
+ rb_obj_class(document) == c_iteration_scope ? Qfalse : Qtrue;
969
968
  st.for_visit = 1;
970
969
  f_node_visit(st.self_ptr, visit_cb, &st);
971
970
  if (st.err != Qnil)
@@ -2648,6 +2647,14 @@ LEPTRIS_INIT_EXPORT void Init_native(void)
2648
2647
  id_iv_c_address = rb_intern("@c_address");
2649
2648
  id_iv_native_cache = rb_intern("@native_cache");
2650
2649
  id_iv_binding_cache = rb_intern("@wrapper_cache");
2650
+ id_iv_c_address = rb_intern("@c_address");
2651
+ id_iv_document = rb_intern("@document");
2652
+ id_iv_parent = rb_intern("@parent");
2653
+ id_iv_structure_memoizable = rb_intern("@structure_memoizable");
2654
+ id_iv_native_fast = rb_intern("@native_fast");
2655
+ id_iv_pub_document = rb_intern("@pub_document");
2656
+ id_iv_addr_reads_fast = rb_intern("@addr_reads_fast");
2657
+ id_iv_node_type = rb_intern("@node_type");
2651
2658
  id_iv_version = rb_intern("@version");
2652
2659
  id_iv_readonly = rb_intern("@readonly");
2653
2660
  id_address = rb_intern("address");
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.222.2"
4
+ VERSION = "1.9.222.3"
5
5
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.222.2
4
+ version: 1.9.222.3
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-22 00:00:00.000000000 Z
11
+ date: 2026-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi