Skip to content

Commit

Permalink
small performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
oweno-tfwm committed Sep 10, 2023
1 parent 951da04 commit 5d28d76
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/atoc_export.R
Original file line number Diff line number Diff line change
Expand Up @@ -587,13 +587,14 @@ afterMidnight <- function(stop_times, safe = TRUE) {
}
}

numb2time2 <- function(numb){
numb2time2 <- function(dt, colNameDest, colNameSource){
#performance, substr is relatively expensive
numb <- sprintf("%02d:%02d:%02d", numb %/% 10000, (numb %/% 100) %% 100, numb %% 100)
set(dt, j=colNameDest, value= sprintf("%02d:%02d:%02d",
dt[[colNameSource]] %/% 10000, (dt[[colNameSource]] %/% 100) %% 100, dt[[colNameSource]] %% 100) )
}

stop_times$arrival_time <- numb2time2(stop_times$arvfinal)
stop_times$departure_time <- numb2time2(stop_times$depfinal)
numb2time2(stop_times, "arrival_time", "arvfinal")
numb2time2(stop_times, "departure_time", "depfinal")

stop_times <- stop_times[, c("trip_id", "arrival_time", "departure_time",
"stop_id", "stop_sequence", "pickup_type",
Expand Down

0 comments on commit 5d28d76

Please sign in to comment.