diff mbox series

[v2,21/21] libcc1: avoid a call to c_str

Message ID 20210428010119.806184-22-tom@tromey.com
State New
Headers show
Series C++11-based improvements for libcc1 | expand

Commit Message

Tom Tromey April 28, 2021, 1:01 a.m. UTC
This is a trivial change to libcc1 to avoid an explicit call to c_str.
Passing by const reference is slightly less wordy.

libcc1/ChangeLog
2021-04-27  Tom Tromey  <tom@tromey.com>

	* compiler.cc (make_regexp): Take const std::string.
	(cc1_plugin::compiler_triplet_regexp::find): Update.
---
 libcc1/ChangeLog   | 5 +++++
 libcc1/compiler.cc | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Jeff Law April 28, 2021, 4:08 p.m. UTC | #1
On 4/27/2021 7:01 PM, Tom Tromey wrote:
> This is a trivial change to libcc1 to avoid an explicit call to c_str.
> Passing by const reference is slightly less wordy.
>
> libcc1/ChangeLog
> 2021-04-27  Tom Tromey  <tom@tromey.com>
>
> 	* compiler.cc (make_regexp): Take const std::string.
> 	(cc1_plugin::compiler_triplet_regexp::find): Update.

OK

jeff
diff mbox series

Patch

diff --git a/libcc1/compiler.cc b/libcc1/compiler.cc
index fede84968625..a12843c538ae 100644
--- a/libcc1/compiler.cc
+++ b/libcc1/compiler.cc
@@ -28,7 +28,7 @@  along with GCC; see the file COPYING3.  If not see
 
 // Construct an appropriate regexp to match the compiler name.
 static std::string
-make_regexp (const char *triplet_regexp, const char *compiler)
+make_regexp (const std::string &triplet_regexp, const char *compiler)
 {
   std::stringstream buf;
 
@@ -71,7 +71,7 @@  char *
 cc1_plugin::compiler_triplet_regexp::find (const char *base,
 					   std::string &compiler) const
 {
-  std::string rx = make_regexp (triplet_regexp_.c_str (), base);
+  std::string rx = make_regexp (triplet_regexp_, base);
   if (verbose)
     fprintf (stderr, _("searching for compiler matching regex %s\n"),
 	     rx.c_str());