tikv / rust-prometheus

Prometheus instrumentation library for Rust applications
Apache License 2.0
1.07k stars 182 forks source link

Migrate from lazy_static to once_cell #448

Open jaudiger opened 2 years ago

jaudiger commented 2 years ago

lazy_static!, while a declarative macro, is a macro nonetheless. It can add quite a bit of additional compilation time cost. once_cell::sync::Lazy does the same thing with generics, and can be used more flexibly (i.e. non-static lazily initialized values), and has been proposed to be added to std: https://github.com/rust-lang/rfcs/pull/2788.

Famous Rust projects already did the transition, such as:

lucab commented 2 years ago

Thanks for the report. Sounds like a good idea! I'll be happy to review a patch doing this if anybody wants to tackle it.

jaudiger commented 2 years ago

Hi @lucab, thanks, I just opened a PR for it !