Skip to content

Eval can be replaced by getfield in select #322

@julbinb

Description

@julbinb

getfield would be more efficient than eval in getting the value of a variable/type here:

prev = :( merge($prev, QueryOperators.NamedTupleUtilities.oftype(_, Val($(eval(Symbol(m_type[1])))))) )

Toy example:

julia> using BenchmarkTools

julia> @btime getfield(Main, Symbol("Int"))
  0.015 ns (0 allocations: 0 bytes)
Int64

julia> @btime eval(Symbol("Int"))
  58.841 ns (0 allocations: 0 bytes)
Int64

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions