From 8356a6be77129256e495d1fd5049dfc6cb6d491e Mon Sep 17 00:00:00 2001 From: Tomasz Leman Date: Wed, 15 Jan 2025 15:17:32 +0100 Subject: [PATCH] clipp: Improve performance by passing parameters as const references This patch addresses performance warnings reported by cppcheck by changing the way parameters are passed in two functions. - In the `operator!` function, the `parameter` type is now passed by const reference instead of by value. This avoids unnecessary copying of the parameter, improving performance. - In the `make_man_page` function, the `doc_string` type is now passed by const reference instead of by value. This change also avoids unnecessary copying and enhances performance. These changes ensure that the functions are more efficient, especially when dealing with larger objects or complex types. Signed-off-by: Tomasz Leman --- include/clipp.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/clipp.h b/include/clipp.h index d7b101e..8f2f15d 100644 --- a/include/clipp.h +++ b/include/clipp.h @@ -3835,7 +3835,7 @@ greedy(parameter p) { } inline parameter -operator ! (parameter p) { +operator ! (const parameter& p) { return greedy(p); } @@ -6851,7 +6851,7 @@ class man_page *****************************************************************************/ inline man_page make_man_page(const group& cli, - doc_string progname = "", + const doc_string& progname = "", const doc_formatting& fmt = doc_formatting{}) { man_page man;