From 0a010a4371c8765996efd943b5240daab6fbf9c6 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Sat, 2 Nov 2019 21:03:35 +0100 Subject: [PATCH] Add comment on performance --- src/macros.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/macros.rs b/src/macros.rs index d2446729..03e518b0 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -479,6 +479,9 @@ macro_rules! crate_authors { self.authors.replace(Some(unwrapped_authors)); unwrapped_authors } else { + // This caches the result for subsequent invocations of the same instance of the macro + // to avoid performing one memory allocation per call. + // If performance ever becomes a problem for this code, it should be moved to build.rs let s: Box = Box::new(env!("CARGO_PKG_AUTHORS").replace(':', $sep)); let static_string = Box::leak(s); self.authors.replace(Some(&*static_string));