leptris 1.9.420.2-ppc64le-linux → 1.9.421.0-ppc64le-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: acbf400bd1622e4796f3005e93271ed5d7660acbd7bba1101c8cbcab1a7dc727
4
- data.tar.gz: c47e0369b06334fc3f4b0912bbbeadd7b9e9ec0eaad5130d6deaedcc4113d2e0
3
+ metadata.gz: abbaf02d5632ebd467f317576cc6aa1601c37bced241e8088d9ca89e3cb09cd0
4
+ data.tar.gz: f011f7acaa3ebc88c913c338a5fe9a31e61428047925267e2dfa8fc9c3bfb97b
5
5
  SHA512:
6
- metadata.gz: d56add39e1e9492b699891bb84ee37e3304552618749e7ff42a41a9cd4681293d48b7aabf66b3d1b59707af36bb9f89e5480b2c7d5606fea217677d5eb2cb35e
7
- data.tar.gz: 83a4da3dc1fa62bbeee4f4ba491fe212cab7039f84b4e590e19516cedab83647c8937fdad1d0b2cd8b8359a311267dae02d7fe44b42c92cd937fe140700b0334
6
+ metadata.gz: 1b11b426af2ac3d0bce6e621d5ec7257fc42b8581e7d853db19cf909d20f935c41ed4747916e66d3c30f8514f41a12bfd2e94af87fafaf0cb1ac7a0811276a95
7
+ data.tar.gz: 31a236ec5fe2e77c8172d123e503faf5c861bb211058b3a4eb2abe01b6a514b34e66917f9e05dd764ed03208c1285713cc2f1c60be5ab77763af42aa1f94f20d
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ RSpec::Core::RakeTask.new(:spec)
8
8
  # Pin for `rake compile` and the platform-gem builds. Keep in lockstep
9
9
  # with .github/workflows/build.yml (which calls `rake compile`) and the
10
10
  # CHANGELOG when libleptris releases.
11
- LIBLEPTRIS_VERSION = "1.9.420"
11
+ LIBLEPTRIS_VERSION = "1.9.421"
12
12
  # Vendored alongside libleptris for fn:normalize-unicode (TODO
13
13
  # .restructure/20): built per platform with a RELOCATABLE @rpath
14
14
  # install name, loaded by ffi.rb before libleptris so the
@@ -83,6 +83,7 @@ static attr_first_fn f_attr_first;
83
83
  static attr_next_fn f_attr_next;
84
84
  static attr_name_fn f_attr_name;
85
85
  static attr_value_fn f_attr_value;
86
+ static const char *(*e_attr_ns_uri)(void *);
86
87
  static attr_pairs_fn f_attr_pairs;
87
88
  static node_line_fn f_node_line;
88
89
  static node_offset_fn f_node_offset;
@@ -323,6 +324,7 @@ static void resolve_symbols(const char *lib_path)
323
324
  f_attr_next = (attr_next_fn)lib_sym(h, "leptris_attribute_next");
324
325
  f_attr_name = (attr_name_fn)lib_sym(h, "leptris_attribute_get_name");
325
326
  f_attr_value = (attr_value_fn)lib_sym(h, "leptris_attribute_get_value");
327
+ e_attr_ns_uri = (const char *(*)(void *))lib_sym(h, "leptris_attribute_namespace_uri");
326
328
  f_attr_pairs = (attr_pairs_fn)lib_sym(h, "leptris_element_attribute_pairs");
327
329
  f_node_line = (node_line_fn)lib_sym(h, "leptris_node_line");
328
330
  f_node_offset = (node_offset_fn)lib_sym(h, "leptris_node_byte_offset");
@@ -1737,11 +1739,22 @@ static VALUE cc_attribute(VALUE self, VALUE name)
1737
1739
  TypedData_Get_Struct(self, struct native_node, &nn_type, n);
1738
1740
  VALUE factory = rb_attr_get(rb_obj_class(self), id_af_factory);
1739
1741
  if (NIL_P(factory)) return Qnil;
1740
- const char *v = f_attr(n->ptr, StringValueCStr(name));
1741
- if (!v) return Qnil;
1742
- return rb_funcall(factory, rb_intern("new"), 3,
1743
- rb_utf8_str_new_cstr(StringValueCStr(name)),
1744
- rb_utf8_str_new_cstr(v), self);
1742
+ const char *needle = StringValueCStr(name);
1743
+ /* Walk to the ATTRIBUTE pointer: the value comes from the
1744
+ * decode-authoritative getter and the namespace URI from the
1745
+ * attr-level face - both need the attr pointer, not the node. */
1746
+ for (void *a = f_attr_first(n->ptr); a; a = f_attr_next(a)) {
1747
+ const char *an = f_attr_name(a);
1748
+ if (!an || strcmp(an, needle) != 0) continue;
1749
+ const char *v = f_attr_value(n->ptr, a);
1750
+ if (!v) return Qnil;
1751
+ const char *uri = e_attr_ns_uri ? e_attr_ns_uri(a) : NULL;
1752
+ return rb_funcall(factory, rb_intern("new"), 4,
1753
+ rb_utf8_str_new_cstr(an),
1754
+ rb_utf8_str_new_cstr(v), self,
1755
+ uri ? rb_utf8_str_new_cstr(uri) : Qnil);
1756
+ }
1757
+ return Qnil;
1745
1758
  }
1746
1759
 
1747
1760
  static VALUE nf_bind_consumer_contract(VALUE self, VALUE klass,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.420.2"
4
+ VERSION = "1.9.421.0"
5
5
  end
Binary file
Binary file
data/lib/libleptris.so CHANGED
Binary file
data/vendor-src/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Sources vendored in this gem (recompile rights; the ruby
2
2
  variant builds them at install via extconf.rb):
3
3
 
4
- - libleptris v1.9.420
4
+ - libleptris v1.9.421
5
5
  - utf8proc v2.11.0
6
6
 
7
7
  Rebuild by hand:
@@ -1,5 +1,16 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.9.421] - 2026-11-15
4
+ ### Performance
5
+
6
+ - **text: the census-gated pristine scan** (leptris#2033 round 2). The `count3_high` sizing pre-scan already counts `&` and tab/LF/CR for the whole buffer — a document with both counts zero has *provably constant* scan flags, so the text branch dispatches to a term-only kernel (`leptris_text_scan_run_pristine`, NEON/AVX2/scalar) whose vector loop carries only the term compare: the f1/f2 accumulator chains drop out entirely, and the round-1 rescan penalty cannot occur because the census already answered the flags. Gate teeth: a DTD custom entity requires the eager entity path (routed by the scan's has_amp flag — the lazy read cannot resolve custom entities), and the new pin fails when the gate is forced open. Local interleaved A/B on the pristine-class 13MB text shape: median +10%.
7
+
8
+ ### CI
9
+
10
+ - **perf-gate: the configure stage installs `libutf8proc-dev`** — the gate had errored without measuring since Nov 13, when the runner-image update (20261111.370) removed the runner copy of utf8proc the gate had been implicitly relying on (found during the release audit).
11
+
12
+
13
+
3
14
  ## [1.9.420] - 2026-11-13
4
15
  ### Fixed
5
16
 
@@ -3,7 +3,7 @@
3
3
  cmake_minimum_required(VERSION 3.20)
4
4
 
5
5
  project(leptris
6
- VERSION 1.9.420
6
+ VERSION 1.9.421
7
7
  DESCRIPTION "Fast XML parser and XPath evaluator in pure C"
8
8
  LANGUAGES C CXX
9
9
  )
@@ -321,6 +321,40 @@ ptrdiff_t leptris_text_scan_run(const char* s, size_t len, char term,
321
321
  return g_scan_run_fn(s, len, term, f1, f2, saw_f1, saw_f2);
322
322
  }
323
323
 
324
+ /* leptris#2033 round 2: the census-gated term-only scan. For
325
+ * documents whose count3_high pre-scan proved zero '&' and zero
326
+ * tab/LF/CR, the f1/f2 accumulator chains are dead weight — the
327
+ * flags are constant 0 by census, so the vector loop carries ONLY
328
+ * the term compare and the no-term tail returns immediately (the
329
+ * round-1 rescan penalty cannot occur: the census answered the
330
+ * flags). Arch kernels live in their own TUs, dispatched like
331
+ * text_scan_run. */
332
+ ptrdiff_t leptris_text_scan_run_pristine(const char* s, size_t len,
333
+ char term,
334
+ int* saw_f1, int* saw_f2) {
335
+ #if defined(LEPTRIS_ARCH_ARM) && defined(__aarch64__)
336
+ return leptris_text_scan_run_pristine_neon(s, len, term,
337
+ saw_f1, saw_f2);
338
+ #elif defined(LEPTRIS_ARCH_X86) && defined(LEPTRIS_HAS_AVX2_BUILD)
339
+ return leptris_text_scan_run_pristine_avx2(s, len, term,
340
+ saw_f1, saw_f2);
341
+ #else
342
+ const char* p = s;
343
+ const char* end = s + len;
344
+ while (p < end) {
345
+ if (*p == term) {
346
+ *saw_f1 = 0;
347
+ *saw_f2 = 0;
348
+ return (ptrdiff_t)(p - s);
349
+ }
350
+ p++;
351
+ }
352
+ *saw_f1 = 0;
353
+ *saw_f2 = 0;
354
+ return -1;
355
+ #endif
356
+ }
357
+
324
358
  /* ---- Structural span scan (TODO 193 Phase 1) ---- */
325
359
 
326
360
  unsigned char leptris_dp_class_table[256];
@@ -98,6 +98,22 @@ ptrdiff_t leptris_text_scan_run(const char* s, size_t len, char term,
98
98
  char f1, char f2,
99
99
  int* saw_f1, int* saw_f2);
100
100
 
101
+ /* The census-gated variant (leptris#2033 round 2): identical
102
+ * contract, for documents whose pre-scan census proved ZERO '&' and
103
+ * zero tab/LF/CR bytes anywhere — the flags are constant 0 and the
104
+ * accumulator chains drop out of the loop. saw_f1/saw_f2 are
105
+ * WRITTEN as 0 (callers read them unconditionally). */
106
+ ptrdiff_t leptris_text_scan_run_pristine(const char* s, size_t len,
107
+ char term,
108
+ int* saw_f1, int* saw_f2);
109
+
110
+ ptrdiff_t leptris_text_scan_run_pristine_neon(const char* s, size_t len,
111
+ char term,
112
+ int* saw_f1, int* saw_f2);
113
+ ptrdiff_t leptris_text_scan_run_pristine_avx2(const char* s, size_t len,
114
+ char term,
115
+ int* saw_f1, int* saw_f2);
116
+
101
117
  /* ---- Structural span scan (TODO 193 Phase 1: parser v3) ----
102
118
  *
103
119
  * Records every byte of the XML structural set in [buf, buf+len)
@@ -370,4 +370,37 @@ int leptris_utf8_valid_avx2(const char* src, size_t len) {
370
370
  if (b >= 0xC2 && b <= 0xF4) start--;
371
371
  }
372
372
  return leptris_utf8_valid_scalar((const char*)(p + start), len - start);
373
- }
373
+ }
374
+
375
+ /* leptris#2033 round 2: the census-gated term-only scan — no
376
+ * accumulator chains (the census proved the flags constant 0). */
377
+ ptrdiff_t leptris_text_scan_run_pristine_avx2(const char* s, size_t len,
378
+ char term,
379
+ int* saw_f1, int* saw_f2) {
380
+ const char* p = s;
381
+ const char* end = s + len;
382
+ const __m256i kt = _mm256_set1_epi8(term);
383
+ while (end - p >= 32) {
384
+ __m256i v = _mm256_loadu_si256((const __m256i*)p);
385
+ uint32_t mt =
386
+ (uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(v, kt));
387
+ if (mt) {
388
+ unsigned idx = (unsigned)LEPTRIS_CTZ(mt);
389
+ *saw_f1 = 0;
390
+ *saw_f2 = 0;
391
+ return (ptrdiff_t)(p + idx - s);
392
+ }
393
+ p += 32;
394
+ }
395
+ while (p < end) {
396
+ if (*p == term) {
397
+ *saw_f1 = 0;
398
+ *saw_f2 = 0;
399
+ return (ptrdiff_t)(p - s);
400
+ }
401
+ p++;
402
+ }
403
+ *saw_f1 = 0;
404
+ *saw_f2 = 0;
405
+ return -1;
406
+ }
@@ -523,3 +523,34 @@ int leptris_utf8_valid_neon(const char* src, size_t len) {
523
523
  return leptris_utf8_valid_scalar((const char*)(p + start), len - start);
524
524
  }
525
525
  #undef IN_RANGE
526
+
527
+ /* leptris#2033 round 2: the census-gated term-only scan — no
528
+ * accumulator chains (the census proved the flags constant 0). */
529
+ ptrdiff_t leptris_text_scan_run_pristine_neon(const char* s, size_t len,
530
+ char term,
531
+ int* saw_f1, int* saw_f2) {
532
+ const char* p = s;
533
+ const char* end = s + len;
534
+ const uint8x16_t kt = vdupq_n_u8((uint8_t)term);
535
+ while (end - p >= 16) {
536
+ if (vmaxvq_u8(vceqq_u8(vld1q_u8((const uint8_t*)p), kt)) != 0) {
537
+ int i = 0;
538
+ while (p[i] != term) i++;
539
+ *saw_f1 = 0;
540
+ *saw_f2 = 0;
541
+ return (ptrdiff_t)(p + i - s);
542
+ }
543
+ p += 16;
544
+ }
545
+ while (p < end) {
546
+ if (*p == term) {
547
+ *saw_f1 = 0;
548
+ *saw_f2 = 0;
549
+ return (ptrdiff_t)(p - s);
550
+ }
551
+ p++;
552
+ }
553
+ *saw_f1 = 0;
554
+ *saw_f2 = 0;
555
+ return -1;
556
+ }
@@ -1574,6 +1574,12 @@ static struct leptris_document* direct_parse_internal(char* buf, size_t len,
1574
1574
  * structural use (pretty-printed docs) conservatively re-arms
1575
1575
  * it, and CR-only line endings keep it armed. */
1576
1576
  int has_copy_sources = (amp_count_in != 0 || valws_count_in != 0);
1577
+ /* leptris#2033 round 2: the census proved zero '&' and zero
1578
+ * tab/LF/CR in the whole buffer — text runs cannot carry the
1579
+ * f1/f2 flags, so the term-only kernel drops the accumulator
1580
+ * chains. The entity/CR branches downstream are unreachable on
1581
+ * this class by the same census. */
1582
+ int pristine_text = (amp_count_in == 0 && valws_count_in == 0);
1577
1583
  /* Track D A3d: the pristine copy exists so doc->xml_buffer stays
1578
1584
  * byte-identical to the input — the lazy line table (#223)
1579
1585
  * counts '\n' against it, and dp_nul may clobber a newline that
@@ -1902,9 +1908,14 @@ static struct leptris_document* direct_parse_internal(char* buf, size_t len,
1902
1908
  int has_cr = 0;
1903
1909
  {
1904
1910
  int saw_amp = 0, saw_cr = 0;
1905
- ptrdiff_t t_off = leptris_text_scan_run(
1906
- p.pos, (size_t)(p.end - p.pos), '<', '&', '\r',
1907
- &saw_amp, &saw_cr);
1911
+ ptrdiff_t t_off =
1912
+ pristine_text
1913
+ ? leptris_text_scan_run_pristine(
1914
+ p.pos, (size_t)(p.end - p.pos), '<',
1915
+ &saw_amp, &saw_cr)
1916
+ : leptris_text_scan_run(
1917
+ p.pos, (size_t)(p.end - p.pos), '<', '&',
1918
+ '\r', &saw_amp, &saw_cr);
1908
1919
  lt = (t_off >= 0) ? (char*)(p.pos + t_off) : NULL;
1909
1920
  has_amp |= saw_amp;
1910
1921
  has_cr |= saw_cr;
@@ -1064,3 +1064,25 @@ TEST(RoundTrip, OoxmlRunPropertiesKeepValAttributes) {
1064
1064
  leptris_free_string(out);
1065
1065
  leptris_document_free(doc);
1066
1066
  }
1067
+
1068
+ /* leptris#2033 round 2 gate teeth: a DTD custom entity requires the
1069
+ * EAGER entity path (the lazy read cannot resolve custom entities),
1070
+ * routed by the text scan's has_amp flag. The census-gated
1071
+ * pristine-text kernel must NEVER take a document whose census
1072
+ * counts '&' — forcing it leaves the entity reference raw. */
1073
+ TEST(Parser, DtdCustomEntityExpandsThroughTheEagerPath) {
1074
+ const char* xml =
1075
+ "<!DOCTYPE r [<!ENTITY x \"hello\">]><r>&x; world</r>";
1076
+ LeptrisStatus st = LEPTRIS_OK;
1077
+ LeptrisDocument doc =
1078
+ leptris_parse_string(xml, std::strlen(xml), &st);
1079
+ ASSERT_EQ(st, LEPTRIS_OK);
1080
+ ASSERT_NE(doc, nullptr);
1081
+ LeptrisElement root = leptris_document_root(doc);
1082
+ ASSERT_NE(root, nullptr);
1083
+ LeptrisNodeRef text =
1084
+ leptris_node_first_child(leptris_element_as_node(root));
1085
+ ASSERT_NE(text, nullptr);
1086
+ EXPECT_STREQ(leptris_text_node_get_content(text), "hello world");
1087
+ leptris_document_free(doc);
1088
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
3
3
  "name": "leptris",
4
- "version": "1.9.420",
4
+ "version": "1.9.421",
5
5
  "description": "High-performance XML parser and XPath 1.0 engine in C (libleptris)",
6
6
  "homepage": "https://github.com/leptris/leptris",
7
7
  "license": "MIT",
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.420.2
4
+ version: 1.9.421.0
5
5
  platform: ppc64le-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-11-14 00:00:00.000000000 Z
11
+ date: 2026-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi