Skip to content

Commit caecc60

Browse files
Move error string creation behind function call to avoid allocations (#1238)
* Move error string creation behind function call to avoid allocations * Add half-edge topology benchmark * Update benchmark/benchmarks.jl * Update benchmark/benchmarks.jl --------- Co-authored-by: Júlio Hoffimann <[email protected]>
1 parent 1cb3215 commit caecc60

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

benchmark/benchmarks.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ SUITE["discretization"] = BenchmarkGroup()
3232

3333
SUITE["discretization"]["simplexify"] = @benchmarkable simplexify($mesh)
3434

35+
# ---------
36+
# TOPOLOGY
37+
# ---------
38+
39+
SUITE["topology"] = BenchmarkGroup()
40+
41+
SUITE["topology"]["half-edge"] = @benchmarkable convert(HalfEdgeTopology, topology($mesh))
42+
3543
# --------
3644
# WINDING
3745
# --------

src/topologies/halfedge.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,7 @@ function HalfEdgeTopology(elems::AbstractVector{<:Connectivity}; sort=true)
208208
if isnothing(he.elem)
209209
he.elem = oelem
210210
else
211-
assertion(
212-
he.elem === oelem,
213-
lazy"duplicate edge $((u, v)) for element $(oelem) is inconsistent with previous edge $he"
214-
)
211+
he.elem === oelem || inconsistentedgeerror(u, v, oelem, he)
215212
end
216213
half = get!(() -> HalfEdge(v, nothing), half4pair, (v, u))
217214
he.half = half
@@ -437,3 +434,6 @@ end
437434
# integer addition mod1
438435
add0(i, n) = i
439436
add1(i, n) = mod1(i + 1, n)
437+
438+
inconsistentedgeerror(u, v, elem, he) =
439+
throw(AssertionError("duplicate edge $((u, v)) for element $(elem) is inconsistent with previous edge $he"))

0 commit comments

Comments
 (0)