Skip to content

Fast path for vec_assign(x, integer())? #1408

Closed as not planned
Closed as not planned
@mgirlich

Description

@mgirlich

Similarly to #1400 I think it would make sense to have a fast path for vec_assign(x, integer())

The motivation is also similar: e.g. when using vec_assign() in a coalesce() like fashion vec_assign(x, is.na(x), 1L).

Benchmark

library(rlang)
library(vctrs)

x <- 0L + 1:10e6

bench::mark(
  vec_assign = {vec_assign(x, integer(), integer())},
  check = FALSE
)
#> # A tibble: 1 x 6
#>   expression      min   median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr> <bch:tm> <bch:tm>     <dbl> <bch:byt>    <dbl>
#> 1 vec_assign    5.1ms   5.53ms      165.    38.2MB     172.

Created on 2021-06-25 by the reprex package (v2.0.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions