leptris 1.9.420.3 → 1.9.421.0

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: ac5960331f264a627e95bb4aafd929a2efd599c427169d685af28a3d844c09e5
4
- data.tar.gz: c63653f92afc6a142fc40877e816d53785b8cfc27cff41bd7b32fdbe0c05f90a
3
+ metadata.gz: 193741921194d636441f339639af69d0fbfc2804bc6bf0aa0fc79297a15e5681
4
+ data.tar.gz: 7c685664bdeef456c3d04808a5295e059faf9be92e92967dff8f07cf369be549
5
5
  SHA512:
6
- metadata.gz: 4c68b0848714db7d2c3160fd1ade4ae81ad6b456fcaa9deed99ec5d4496c598d1c30e75dde68e54daef6145561f5642d69099afd4bfc64e5fd79a0cb648fb767
7
- data.tar.gz: aec7de55dbf83e7b1710215471d1232c642918531feded58b2d8dec43b028531cfd970238e4b0c37385f398447ac659a6beb413c9903d4f3935d41d1fae727e0
6
+ metadata.gz: 5deb550a092fc2273d9ae15986c674cdb227df305b30d1019dea6cf2f362098bd7f373440ecf0c50c04a51b8f852ccac7ca30f2366e7b3316654df594958da48
7
+ data.tar.gz: f3a6aec62f2f2220c1361a1a1715cdbd6cfac69d17e3983b182634e070d6518532f5d11504def070dc07a2030e38b928d9b72dae135c88edb2c3732028f38cec
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leptris
4
- VERSION = "1.9.420.3"
4
+ VERSION = "1.9.421.0"
5
5
  end
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.420.3
4
+ version: 1.9.421.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.