metanorma 2.5.23 → 2.5.24
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/lib/metanorma/collection/renderer/svg.rb +25 -5
- data/lib/metanorma/version.rb +1 -1
- 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: 5b7f24f8333462e860db4b5e24a6e92f48da2c2ce8dc53f42d0b91da79ffbd9b
|
|
4
|
+
data.tar.gz: b3496f8ce83f4ccdc72b7f757b12ad2108d938de33764b5a7e6be86426f15ffe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5bc44aaac9aed93d4f70d7a31e15874f8fc37a13d6e222d5f24d5d36dddd7ba8cb1f60e218c574e4be835c8fc309669c3e51f4f03fa1c346f93dfc6ecc42c27f
|
|
7
|
+
data.tar.gz: de64618a5753ed9cf54632ccc79847dc19f836ad805ec7d04f18389eb358ca246d54b63066cfd5bde11db9a46093c8b8b0f862837291aca40ad9c0be9287f1fa
|
|
@@ -416,15 +416,35 @@ module Metanorma
|
|
|
416
416
|
# name (geometry_schema.cartesian_point_ISO_10303-42_2025_...), so
|
|
417
417
|
# the plain name resolves by prefix. Multiple equal-length matches
|
|
418
418
|
# are ambiguous and refuse, as do differing ids at the same key.
|
|
419
|
+
# Memoized per prefix: the index is immutable once built, and a
|
|
420
|
+
# mega-member's svgmap erefs hit this per stage pass (the linear
|
|
421
|
+
# scan showed up at 24%+ of a 104-style render's wall).
|
|
419
422
|
def hotspot_prefix_lookup(idx, prefix)
|
|
420
|
-
|
|
423
|
+
@hotspot_prefix_memo ||= {}
|
|
424
|
+
@hotspot_prefix_memo.fetch(prefix) do
|
|
425
|
+
@hotspot_prefix_memo[prefix] =
|
|
426
|
+
idx[prefix] || prefix_lookup_scan(idx, prefix)
|
|
427
|
+
end
|
|
428
|
+
end
|
|
421
429
|
|
|
422
|
-
|
|
430
|
+
# Candidate keys sharing the prefix, by binary search over the
|
|
431
|
+
# sorted index keys: keys with the stem prefix are contiguous in
|
|
432
|
+
# sort order, so the slice between the lower bound and the first
|
|
433
|
+
# non-matching key is the entire candidate set.
|
|
434
|
+
def prefix_lookup_scan(idx, prefix)
|
|
435
|
+
stem = "#{prefix}_"
|
|
436
|
+
keys = hotspot_sorted_keys(idx)
|
|
437
|
+
lo = keys.bsearch_index { |k| k >= stem } or return nil
|
|
438
|
+
candidates = keys[lo..].take_while { |k| k.start_with?(stem) }
|
|
423
439
|
return nil if candidates.empty?
|
|
424
440
|
|
|
425
|
-
shortest = candidates.min_by
|
|
426
|
-
ties = candidates.count { |k
|
|
427
|
-
ties == 1 ? shortest
|
|
441
|
+
shortest = candidates.min_by(&:length)
|
|
442
|
+
ties = candidates.count { |k| k.length == shortest.length }
|
|
443
|
+
ties == 1 ? idx[shortest] : nil
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
def hotspot_sorted_keys(idx)
|
|
447
|
+
@hotspot_sorted_keys ||= idx.keys.select { |k| idx[k] }.sort
|
|
428
448
|
end
|
|
429
449
|
end
|
|
430
450
|
end
|
data/lib/metanorma/version.rb
CHANGED