This is an automated email from the ASF dual-hosted git repository.
hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-cpp.git
The following commit(s) were added to refs/heads/master by this push:
new 78b5968 perf: Pass logging arguments as const-ref to prevent
repetitive copying (#278)
78b5968 is described below
commit 78b59682f81bdaac01c767ab7ff059459cfca437
Author: Carsten Bäcker <[email protected]>
AuthorDate: Sat Oct 31 02:48:44 2026 +0100
perf: Pass logging arguments as const-ref to prevent repetitive copying
(#278)
---
casbin/logger.cpp | 4 ++--
include/casbin/log/Logger.h | 6 +++---
include/casbin/log/default_logger.h | 6 +++---
include/casbin/log/log_util.h | 6 +++---
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/casbin/logger.cpp b/casbin/logger.cpp
index dd311f0..b5b56d6 100644
--- a/casbin/logger.cpp
+++ b/casbin/logger.cpp
@@ -10,13 +10,13 @@ namespace casbin {
// Print formats using the default formats for its operands and logs the
message.
template <typename T, typename... Object>
-void Logger::Print(T arg, Object... objects) {
+void Logger::Print(T const& arg, Object const&... objects) {
return;
}
// Printf formats according to a format specifier and logs the message.
template <typename... Object>
-void Logger::Printf(std::string format, Object... objects) {
+void Logger::Printf(std::string const& format, Object const&... objects) {
Print(objects...);
}
diff --git a/include/casbin/log/Logger.h b/include/casbin/log/Logger.h
index bf3be10..380db88 100644
--- a/include/casbin/log/Logger.h
+++ b/include/casbin/log/Logger.h
@@ -18,13 +18,13 @@ public:
// Print formats using the default formats for its operands and logs the
message.
template <typename T, typename... Object>
- void Print(T arg, Object... objects);
+ void Print(T const& arg, Object const&... objects);
// Printf formats according to a format specifier and logs the message.
template <typename... Object>
- void Printf(std::string, Object... objects);
+ void Printf(std::string const& format, Object const&... objects);
};
} // namespace casbin
-#endif
\ No newline at end of file
+#endif
diff --git a/include/casbin/log/default_logger.h
b/include/casbin/log/default_logger.h
index 9e8e90a..ce7b7f5 100644
--- a/include/casbin/log/default_logger.h
+++ b/include/casbin/log/default_logger.h
@@ -12,14 +12,14 @@ public:
bool IsEnabled() { return m_enable; }
template <typename... Object>
- void Print(Object... objects) {
+ void Print(Object const&... objects) {
if (m_enable) {
Print(objects...);
}
}
template <typename... Object>
- void Print(std::string format, Object... objects) {
+ void Print(std::string const& format, Object const&... objects) {
if (m_enable) {
Printf(format, objects...);
}
@@ -28,4 +28,4 @@ public:
} // namespace casbin
-#endif
\ No newline at end of file
+#endif
diff --git a/include/casbin/log/log_util.h b/include/casbin/log/log_util.h
index c934067..5a709da 100644
--- a/include/casbin/log/log_util.h
+++ b/include/casbin/log/log_util.h
@@ -18,17 +18,17 @@ public:
// LogPrint prints the log.
template <typename... Object>
- static void LogPrint(Object... objects) {
+ static void LogPrint(Object const&... objects) {
s_logger.Print(objects...);
}
// LogPrintf prints the log with the format.
template <typename... Object>
- static void LogPrintf(std::string format, Object... objects) {
+ static void LogPrintf(std::string const& format, Object const&... objects)
{
s_logger.Printf(format, objects...);
}
};
} // namespace casbin
-#endif
\ No newline at end of file
+#endif
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]