Three read-only substitutions for repeated star/point-location queries - #9591
Open
IasonManolas wants to merge 3 commits into
Open
Three read-only substitutions for repeated star/point-location queries#9591IasonManolas wants to merge 3 commits into
IasonManolas wants to merge 3 commits into
Conversation
… edge A non-boundary edge's incident cells all share one subdomain, so a point-location query of its midpoint is redundant: e.first already carries the answer. The locate is kept as an expensive assertion.
…the star surface_patch_index() collected a vertex's whole incident-facet star into a small_vector before scanning it for the first complex facet. Streaming through incident_facets() with a function output iterator removes the collection; the scan stops doing work at the first match the same way the old loop's break did.
…ngths are_edge_lengths_valid() visits the incident edges of both endpoints of a collapsed edge, so a vertex adjacent to both is visited twice; the sizing field was re-queried on the repeat even though the test reads nothing but the vertex handle. Tracking already-examined vertices in a flat_set and skipping repeats removes the redundant query.
janetournois
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three independent optimizations, grouped together because each is a small, self-contained
substitution of a cheaper read for a query that a nearby invariant already answers:
midpoint_with_info()located anon-boundary edge's midpoint with
subdomain_index_at_point_3(), a full point-location query,purely to learn its subdomain. Every cell incident to a non-boundary edge shares one subdomain,
since
is_boundary()is exactly the test that rules out a facet of the complex or a subdomainchange around the edge. The midpoint lies on the edge, so a locate can only return one of those
incident cells, and
e.firstalready is one. Readinge.first->subdomain_index()gives thesame answer without the query. The locate is kept as a
CGAL_expensive_assertion.surface_patch_index()collected avertex's entire incident-facet star into a
small_vector, then scanned it for the first facetbelonging to the complex. Streaming through a function output iterator instead removes the
collection and stops at the first match, same as the scan already did.
are_edge_lengths_valid()visits theincident edges of both endpoints of a collapsed edge, so a vertex adjacent to both is visited
twice; the squared length was recomputed and re-queried from the sizing field on the repeat
even though the loop's own test reads nothing but the vertex handle. Tracking already-examined
vertices in a
flat_setand skipping repeats removes the redundant sizing-field query.Testing
Verdict equivalence. All three changes are read-only substitutions or streaming equivalents
over predicates already determined by the triangulation's invariants; none change which edge,
vertex, or collapse is selected, or in what order. Full test suite (all executables in
test/Tetrahedral_remeshing) passes.Byte-identical output, against plain
cgal/main:Performance.
perf stat -e instructions, Linux, Release, sequential, against plaincgal/main.cgal/maininstrRelease Management