Skip to content

Commit f5520fa

Browse files
committed
reduce allocation in byrow(sort)
1 parent 1a34561 commit f5520fa

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/byrow/hp_row_functions.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function hp_row_sort!(ds::Dataset, cols = names(ds, Union{Missing, Number}); kwargs...)
22
colsidx = index(ds)[cols]
3-
T = mapreduce(eltype, promote_type, eachcol(ds)[colsidx])
3+
T = mapreduce(eltype, promote_type, view(_columns(ds),colsidx))
44
m = Matrix{T}(ds[!, colsidx])
55
Threads.@threads for i in 1:size(m, 1)
66
@views sort!(m[i, :]; kwargs...)

src/byrow/row_functions.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ end
10041004

10051005
function row_sort!(ds::Dataset, cols = names(ds, Union{Missing, Number}); kwargs...)
10061006
colsidx = index(ds)[cols]
1007-
T = mapreduce(eltype, promote_type, eachcol(ds)[colsidx])
1007+
T = mapreduce(eltype, promote_type, view(_columns(ds),colsidx))
10081008
m = Matrix{T}(ds[!, colsidx])
10091009
sort!(m; dims = 2, kwargs...)
10101010
for i in 1:length(colsidx)

0 commit comments

Comments
 (0)