From 84cffab914543fe2fecb644ef2409b6f5e6b2d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Tue, 5 Mar 2024 21:59:37 +0100 Subject: [PATCH] Add sizehint! to intermediate storage --- src/CornerPointGrid/processing.jl | 14 ++++++++++---- src/CornerPointGrid/processing_utils.jl | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/CornerPointGrid/processing.jl b/src/CornerPointGrid/processing.jl index 5becd45..463a208 100644 --- a/src/CornerPointGrid/processing.jl +++ b/src/CornerPointGrid/processing.jl @@ -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 diff --git a/src/CornerPointGrid/processing_utils.jl b/src/CornerPointGrid/processing_utils.jl index 2997215..d41516c 100644 --- a/src/CornerPointGrid/processing_utils.jl +++ b/src/CornerPointGrid/processing_utils.jl @@ -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