leptris 1.9.406.0-aarch64-linux → 1.9.406.1-aarch64-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 +4 -4
- data/ext/leptris/native/native.c +25 -0
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/attr.rb +20 -5
- data/lib/leptris/xml/document.rb +3 -0
- data/lib/leptris/xml/element.rb +5 -3
- data/lib/leptris/xml/native.so +0 -0
- data/lib/leptris/xml/native_3_3.so +0 -0
- data/lib/leptris/xml/native_layer.rb +11 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c746e7ae73432ca3b73e0b9d948385430330e9eeb780e6f5ebd6ef72d1d8875b
|
|
4
|
+
data.tar.gz: 90701954e9fbbcefdf0ce583beaa5a54255c4b307e1dd671de1a5282064e9760
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dfa958cfb2278dfdf541261d72f52cd2334b99d1ee98bc2edfe477955329a7e344147351c2f63c166dc445f0453bc9361c2ff525b2096202ff0b371624066425
|
|
7
|
+
data.tar.gz: de2628a994bd2b2f24e4eed7df28ca137a585d89ec047942ffea243603b5af6200f358f9e35fae32a1f3dddfeb20d1208e56a4fea76b4867bcbc3fb85f0b267c
|
data/ext/leptris/native/native.c
CHANGED
|
@@ -3255,6 +3255,29 @@ static VALUE nf_attribute_rows(VALUE self, VALUE document, VALUE addr)
|
|
|
3255
3255
|
return out;
|
|
3256
3256
|
}
|
|
3257
3257
|
|
|
3258
|
+
/* ruby#586 ask 1: the flat packet face — [name1, value1, ...] in one
|
|
3259
|
+
* crossing, with no per-attribute Attr/Pointer objects, no slice
|
|
3260
|
+
* arrays and no identity-cache writes. Names interned, values fresh.
|
|
3261
|
+
* Read-only consumers zip the flat array themselves. */
|
|
3262
|
+
static VALUE nf_attribute_packet(VALUE self, VALUE document, VALUE addr)
|
|
3263
|
+
{
|
|
3264
|
+
(void)self;
|
|
3265
|
+
(void)document;
|
|
3266
|
+
void *node = (void *)(uintptr_t)NUM2ULL(addr);
|
|
3267
|
+
VALUE out = rb_ary_new();
|
|
3268
|
+
if (f_node_type(node) != WS_NODE_ELEMENT) return out;
|
|
3269
|
+
|
|
3270
|
+
for (void *a = f_attr_first(node); a; a = f_attr_next(a)) {
|
|
3271
|
+
const char *an = f_attr_name(a);
|
|
3272
|
+
const char *av = f_attr_value(node, a);
|
|
3273
|
+
rb_ary_push(out, an ? rb_enc_interned_str(an, strlen(an),
|
|
3274
|
+
rb_utf8_encoding())
|
|
3275
|
+
: Qnil);
|
|
3276
|
+
rb_ary_push(out, av ? rb_utf8_str_new_cstr(av) : Qnil);
|
|
3277
|
+
}
|
|
3278
|
+
return out;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3258
3281
|
static VALUE nf_plan_structs(VALUE self, VALUE document, VALUE addr,
|
|
3259
3282
|
VALUE spec)
|
|
3260
3283
|
{
|
|
@@ -4266,6 +4289,8 @@ static void leptris_native_setup(void)
|
|
|
4266
4289
|
nf_plan_structs, 3);
|
|
4267
4290
|
rb_define_module_function(m_native, "attribute_rows",
|
|
4268
4291
|
nf_attribute_rows, 2);
|
|
4292
|
+
rb_define_module_function(m_native, "attribute_packet",
|
|
4293
|
+
nf_attribute_packet, 2);
|
|
4269
4294
|
rb_define_module_function(m_native, "create_element_with_attrs",
|
|
4270
4295
|
nf_create_element_with_attrs, 4);
|
|
4271
4296
|
rb_define_module_function(m_native, "register_doc_klasses",
|
data/lib/leptris/version.rb
CHANGED
data/lib/leptris/xml/attr.rb
CHANGED
|
@@ -8,9 +8,12 @@
|
|
|
8
8
|
class Leptris::XML::Attr
|
|
9
9
|
attr_reader :name, :value, :element
|
|
10
10
|
|
|
11
|
-
# c_handle is the C LeptrisAttribute
|
|
12
|
-
# element's iteration face — document-owned and borrowed.
|
|
13
|
-
#
|
|
11
|
+
# c_handle is the C LeptrisAttribute handle from the owning
|
|
12
|
+
# element's iteration face — document-owned and borrowed. The rows
|
|
13
|
+
# faces pass the raw Integer address (ruby#586 ask 2: no
|
|
14
|
+
# per-attribute FFI::Pointer on read-only callers); the Pointer is
|
|
15
|
+
# minted lazily on the first namespace read. Hand constructors may
|
|
16
|
+
# pass a Pointer directly, or nil when constructed by hand.
|
|
14
17
|
def initialize(name, value, element, c_handle: nil)
|
|
15
18
|
@name = name
|
|
16
19
|
@value = value
|
|
@@ -37,8 +40,9 @@ class Leptris::XML::Attr
|
|
|
37
40
|
# nil for a no-namespace attribute or an undeclared prefix; xml
|
|
38
41
|
# is prebound to http://www.w3.org/XML/1998/namespace.
|
|
39
42
|
def namespace_uri
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
h = c_handle_ptr
|
|
44
|
+
return nil if h.nil?
|
|
45
|
+
Leptris::XML::FFI.leptris_attribute_namespace_uri(h)
|
|
42
46
|
end
|
|
43
47
|
|
|
44
48
|
def namespace
|
|
@@ -73,4 +77,15 @@ class Leptris::XML::Attr
|
|
|
73
77
|
def inspect
|
|
74
78
|
"#<#{self.class.name} name=#{@name.inspect} value=#{@value.inspect}>"
|
|
75
79
|
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
# Wrap a raw Integer address on first namespace read; Pointer and
|
|
84
|
+
# nil pass through unchanged.
|
|
85
|
+
def c_handle_ptr
|
|
86
|
+
if @c_handle.is_a?(Integer)
|
|
87
|
+
@c_handle = @c_handle.zero? ? nil : FFI::Pointer.new(@c_handle)
|
|
88
|
+
end
|
|
89
|
+
@c_handle
|
|
90
|
+
end
|
|
76
91
|
end
|
data/lib/leptris/xml/document.rb
CHANGED
|
@@ -714,6 +714,9 @@ class Leptris::XML::Document
|
|
|
714
714
|
@c_ptr = nil
|
|
715
715
|
@c_address = nil
|
|
716
716
|
@wrapper_cache&.clear
|
|
717
|
+
# ruby#587: release the native identity cache at free time —
|
|
718
|
+
# the wrapper set dies with the document, not at GC time.
|
|
719
|
+
@native_cache = nil
|
|
717
720
|
# Detach the lifetime handle (TODO.perf/12): the memory is
|
|
718
721
|
# already released above — the GC-pass dfree must no-op.
|
|
719
722
|
Leptris::XML::Native.doc_handle_release(self) if defined?(Leptris::XML::NATIVE_FAST)
|
data/lib/leptris/xml/element.rb
CHANGED
|
@@ -411,13 +411,15 @@ class Leptris::XML::Element < Leptris::XML::Node
|
|
|
411
411
|
# address] triples; the Attr value objects are minted from them
|
|
412
412
|
# with zero further engine crossings — identical objects to
|
|
413
413
|
# each_attribute. The win amplifies with attribute density
|
|
414
|
-
# (40-attr elements list ~7x faster than the chain).
|
|
414
|
+
# (40-attr elements list ~7x faster than the chain). The raw
|
|
415
|
+
# Integer address rides along (ruby#586 ask 2) — the FFI::Pointer
|
|
416
|
+
# is minted lazily on the first namespace read, so read-only
|
|
417
|
+
# walkers stop paying one Pointer per attribute.
|
|
415
418
|
def attribute_rows_native
|
|
416
419
|
::Leptris::XML::Native.attribute_rows(@document, @c_address)
|
|
417
420
|
.each_slice(3)
|
|
418
421
|
.map do |name, value, handle|
|
|
419
|
-
::Leptris::XML::Attr.new(name, value, self,
|
|
420
|
-
c_handle: ::FFI::Pointer.new(handle))
|
|
422
|
+
::Leptris::XML::Attr.new(name, value, self, c_handle: handle)
|
|
421
423
|
end
|
|
422
424
|
end
|
|
423
425
|
|
data/lib/leptris/xml/native.so
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -105,6 +105,17 @@ class Leptris::XML::Document
|
|
|
105
105
|
@native_cache ||= {}
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
+
# ruby#587 ask 2: documented drop point for the identity cache —
|
|
109
|
+
# a parse -> hydrate -> discard lane releases the retained wrapper
|
|
110
|
+
# set without waiting for document GC. Surviving wrappers stay
|
|
111
|
+
# valid (they carry their own document + address); new crossings
|
|
112
|
+
# mint fresh wrappers, so the object-identity contract ends where
|
|
113
|
+
# the host says it ends.
|
|
114
|
+
def clear_native_cache
|
|
115
|
+
@native_cache = nil
|
|
116
|
+
self
|
|
117
|
+
end
|
|
118
|
+
|
|
108
119
|
def native_node
|
|
109
120
|
r = root or raise Leptris::XML::Error, "document has no root element"
|
|
110
121
|
Leptris::XML::NativeNode.from(self, r.c_ptr)
|