commit 4d5d1435a785cc93a30f4ea97cdd7125f19da32c
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Sat Jun 21 17:50:19 2025 +0200
Use const reference for string for performance
Spotted by cppcheck.
---
src/DispatchResult.h | 2 +-
src/support/FileName.cpp | 2 +-
src/support/FileName.h | 2 +-
src/support/Lexer.cpp | 4 ++--
src/support/qstring_helpers.cpp | 2 +-
src/support/qstring_helpers.h | 2 +-
src/support/unicode.h | 2 +-
7 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/DispatchResult.h b/src/DispatchResult.h
index c41b4c5b67..01a06c267e 100644
--- a/src/DispatchResult.h
+++ b/src/DispatchResult.h
@@ -37,7 +37,7 @@ public:
///
void setError(bool e) { error_ = e; }
///
- docstring message() const { return message_; }
+ docstring const & message() const { return message_; }
///
void setMessage(docstring const & m) { message_ = m; }
///
diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp
index b64920feb9..a9b54f2bcd 100644
--- a/src/support/FileName.cpp
+++ b/src/support/FileName.cpp
@@ -185,7 +185,7 @@ bool FileName::isAbsolute(string const & name)
}
-string FileName::absFileName() const
+string const & FileName::absFileName() const
{
return d->name;
}
diff --git a/src/support/FileName.h b/src/support/FileName.h
index 4611ee8b6f..2ecb3be5a6 100644
--- a/src/support/FileName.h
+++ b/src/support/FileName.h
@@ -64,7 +64,7 @@ public:
static bool isAbsolute(std::string const & name);
/// get the absolute file name in UTF-8 encoding
- std::string absFileName() const;
+ std::string const & absFileName() const;
/** returns an absolute pathname (whose resolution does not involve
* '.', '..', or symbolic links) in UTF-8 encoding
diff --git a/src/support/Lexer.cpp b/src/support/Lexer.cpp
index fd8840d1a3..b4a4f6b697 100644
--- a/src/support/Lexer.cpp
+++ b/src/support/Lexer.cpp
@@ -50,7 +50,7 @@ public:
///
Pimpl(LexerKeyword * tab, int num);
///
- string const getString() const;
+ string const & getString() const;
///
docstring const getDocString() const;
///
@@ -153,7 +153,7 @@ Lexer::Pimpl::Pimpl(LexerKeyword * tab, int num)
}
-string const Lexer::Pimpl::getString() const
+string const & Lexer::Pimpl::getString() const
{
return buff;
}
diff --git a/src/support/qstring_helpers.cpp b/src/support/qstring_helpers.cpp
index e39dc7fb33..5323b0a438 100644
--- a/src/support/qstring_helpers.cpp
+++ b/src/support/qstring_helpers.cpp
@@ -112,7 +112,7 @@ QString locLengthString(QString const & str)
}
-docstring locLengthDocString(docstring const str)
+docstring locLengthDocString(docstring const & str)
{
return qstring_to_ucs4(locLengthString(toqstr(str)));
}
diff --git a/src/support/qstring_helpers.h b/src/support/qstring_helpers.h
index bb608b2334..76d6f610b2 100644
--- a/src/support/qstring_helpers.h
+++ b/src/support/qstring_helpers.h
@@ -96,7 +96,7 @@ QString charFilterRegExpC(QString const & filter);
QString locLengthString(QString const & str);
/// Same for doscstring
-docstring locLengthDocString(docstring const str);
+docstring locLengthDocString(docstring const & str);
/// Method to replace localized decimal separator by dot
QString unlocLengthString(QString const & str);
diff --git a/src/support/unicode.h b/src/support/unicode.h
index a8befa54bd..2cbedf367f 100644
--- a/src/support/unicode.h
+++ b/src/support/unicode.h
@@ -60,7 +60,7 @@ public:
int convert(char const * in_buffer, size_t in_size,
char * out_buffer, size_t max_out_size);
/// target encoding
- std::string to() const { return tocode_; }
+ std::string const & to() const { return tocode_; }
};
/// Get the global IconvProcessor instance of the current thread for
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs