From a4ed90fee90d1ae039d0c1ebf39b0de64543d3f3 Mon Sep 17 00:00:00 2001 From: Gregory Jefferis Date: Thu, 30 Jan 2020 18:27:29 +0000 Subject: [PATCH] speed up as.seglist.igraph * picked up when working on #424 with Sri as was taking a big part of the time in stitch_neurons_mst * closes #425 * it is *way* faster to operate on a base list object and then turn it into a seglist when done. --- R/seglist.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/seglist.R b/R/seglist.R index e4b78819..2c74fce4 100644 --- a/R/seglist.R +++ b/R/seglist.R @@ -130,7 +130,7 @@ as.seglist.igraph<-function(x, origin=NULL, Verbose=FALSE, ...){ # _original_ vertex ids specified by "vid" attribute of input graph curseg=vids[orders[1]] if(length(ncount)==1) stop("Unexpected singleton point found!") - sl=seglist() + sl=list() # we have more than 1 point in graph and some work to do! fathers=as.integer(dfs$father) for(i in seq.int(from=2,to=length(dfs$order))){ @@ -148,7 +148,9 @@ as.seglist.igraph<-function(x, origin=NULL, Verbose=FALSE, ...){ curseg=integer(0) } } - sl + # nb it is *way* faster to operate on a base list object + # and then turn it into a seglist when done. + as.seglist(sl) } #' Recalculate Neurons's SWCData using SegList and point information