Skip to content

Commit fd65418

Browse files
committed
logic cleanup
1 parent 28ce7e0 commit fd65418

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/decompositions.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@ end
4949
function tet_to_edges!(pair::Vector, pair_set::Set, t)
5050
empty!(pair_set)
5151
length(pair) < length(t)*6 && resize!(pair, length(t)*6)
52-
num_pair = 1
52+
num_pair = 0
5353
@inbounds for i in eachindex(t)
5454
for ep in 1:6
5555
p1 = t[i][tetpairs[ep][1]]
5656
p2 = t[i][tetpairs[ep][2]]
5757
elt = p1 > p2 ? (p2,p1) : (p1,p2)
5858
if !in(elt, pair_set)
5959
push!(pair_set, elt)
60-
pair[num_pair] = elt
6160
num_pair += 1
61+
pair[num_pair] = elt
6262
end
6363
end
6464
end
6565

6666
# sort the edge pairs for better point lookup
67-
sort!(view(pair, 1:(num_pair-1)))
67+
sort!(view(pair, 1:num_pair))
6868

69-
return num_pair - 1 # return the number of pairs
69+
return num_pair # return the number of pairs
7070
end
7171

7272
function bitpack(xi,yi)

src/distmeshnd.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ function distmesh(fdist::Function,
107107
num_pairs = tet_to_edges!(pair, pair_set, result.tetrahedra) # Describe each edge by a unique pair of nodes
108108

109109
# resize arrays for new pair count
110-
length(bars) < num_pairs && resize!(bars, num_pairs)
111-
length(L) < num_pairs && resize!(L, num_pairs)
112-
non_uniform && length(L0) < num_pairs && resize!(L0, num_pairs)
110+
if length(L) < num_pairs
111+
resize!(bars, num_pairs)
112+
resize!(L, num_pairs)
113+
non_uniform && resize!(L0, num_pairs)
114+
end
113115

114116
triangulationcount += 1
115117
stats && push!(result.stats.retriangulations, lcount)

0 commit comments

Comments
 (0)