@@ -96,12 +96,12 @@ add_cache_block <- function(pd_nested) {
9696shallowify <- function (pd ) {
9797 if (cache_is_activated()) {
9898 order <- order(pd $ line1 , pd $ col1 , - pd $ line2 , - pd $ col2 , as.integer(pd $ terminal ))
99- pd_parent_first <- pd [ order , ]
100- pos_ids_to_keep <- pd_parent_first % > %
101- split(cumsum( pd_parent_first $ parent == 0L )) %> %
99+ pd_parent_first <- vec_slice( pd , order )
100+ pd_parent_first_split <- vec_split( pd_parent_first , cumsum( pd_parent_first $ parent == 0L ))
101+ pos_ids_to_keep <- pd_parent_first_split [[ 2L ]] %> %
102102 map(find_pos_id_to_keep ) %> %
103103 unlist(use.names = FALSE )
104- shallow <- pd [ pd $ pos_id %in% pos_ids_to_keep , ]
104+ shallow <- vec_slice( pd , pd $ pos_id %in% pos_ids_to_keep )
105105 shallow $ terminal [shallow $ is_cached ] <- TRUE
106106 # all cached expressions need to be marked as terminals because to
107107 # [apply_stylerignore()], we rely on terminals only.
@@ -332,10 +332,9 @@ nest_parse_data <- function(pd_flat) {
332332 return (pd_flat )
333333 }
334334 pd_flat $ internal <- with(pd_flat , (id %in% parent ) | (parent < = 0L ))
335- split_data <- split(pd_flat , pd_flat $ internal )
336335
337- child <- split_data $ `FALSE`
338- internal <- split_data $ `TRUE`
336+ child <- vec_slice( pd_flat , ! pd_flat $ internal )
337+ internal <- vec_slice( pd_flat , pd_flat $ internal )
339338
340339 internal $ internal_child <- internal $ child
341340 internal $ child <- NULL
@@ -364,14 +363,14 @@ nest_parse_data <- function(pd_flat) {
364363# ' the correct order.
365364# ' @param child A parse table or `NULL`.
366365# ' @param internal_child A parse table or `NULL`.
367- # ' @details Essentially, this is a wrapper around [dplyr::bind_rows ()], but
368- # ' returns `NULL` if the result of [dplyr::bind_rows ()] is a data frame with
366+ # ' @details Essentially, this is a wrapper around vctrs::vec_rbind ()], but
367+ # ' returns `NULL` if the result of vctrs::vec_rbind ()] is a data frame with
369368# ' zero rows.
370369# ' @keywords internal
371370combine_children <- function (child , internal_child ) {
372- bound <- bind_rows (child , internal_child )
371+ bound <- vec_rbind (child , internal_child )
373372 if (nrow(bound ) == 0L ) {
374373 return (NULL )
375374 }
376- bound [ order(bound $ pos_id ), ]
375+ vec_slice( bound , order(bound $ pos_id ))
377376}
0 commit comments