Skip to content

Commit

Permalink
Add sizehint! to intermediate storage
Browse files Browse the repository at this point in the history
  • Loading branch information
moyner committed Mar 5, 2024
1 parent 2c75853 commit 84cffab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/CornerPointGrid/processing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ function cpgrid_primitives(coord, zcorn, cartdims; actnum = missing, pinch = mis
@assert nliney*nlinex == size(coord, 1)

function generate_line(p1, p2)
line_length_hint = nz
z = sizehint!(Vector{Float64}(), line_length_hint)
cells = sizehint!(Vector{Int}(), line_length_hint)
cellpos = sizehint!(Vector{Int}(), line_length_hint)
nodes = sizehint!(Vector{Int}(), line_length_hint)

return (
z = Vector{Float64}(),
cells = Vector{Int}(),
cellpos = Vector{Int}(),
nodes = Vector{Int}(),
z = z,
cells = cells,
cellpos = cellpos,
nodes = nodes,
x1 = SVector{3, Float64}(p1),
x2 = SVector{3, Float64}(p2),
equal_points = p1 p2
Expand Down
1 change: 1 addition & 0 deletions src/CornerPointGrid/processing_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ function traverse_column_pair(col_a, col_b, l1, l2)

ord_a = cell_top_bottom(col_a.cells, l1, l2)
ord_b = cell_top_bottom(col_b.cells, l1, l2)
sizehint!(overlaps, max(length(ord_a), length(ord_b)))
function get_local_line(pos, is_line1::Bool)
if is_line1
d = pos.line1
Expand Down

0 comments on commit 84cffab

Please sign in to comment.