diff mbox series

[v2,20/21] libcc1: avoid extra string copies

Message ID 20210428010119.806184-21-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
PR c/94669 points out that a couple of spots in libcc1 take a
std::string where a reference would do.  This changes these spots to
take a const char *, to reduce the number of copies.

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

	PR c/94669:
	* compiler.hh (compiler_driver_filename): Take const char *.
	(compiler_triplet_regexp): Likewise.
---
 libcc1/ChangeLog   | 6 ++++++
 libcc1/compiler.hh | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Jeff Law April 28, 2021, 4:07 p.m. UTC | #1
On 4/27/2021 7:01 PM, Tom Tromey wrote:
> PR c/94669 points out that a couple of spots in libcc1 take a
> std::string where a reference would do.  This changes these spots to
> take a const char *, to reduce the number of copies.
>
> libcc1/ChangeLog
> 2021-04-27  Tom Tromey  <tom@tromey.com>
>
> 	PR c/94669:
> 	* compiler.hh (compiler_driver_filename): Take const char *.
> 	(compiler_triplet_regexp): Likewise.

OK

jeff
diff mbox series

Patch

diff --git a/libcc1/compiler.hh b/libcc1/compiler.hh
index 638f7c09f634..d10d409f9d35 100644
--- a/libcc1/compiler.hh
+++ b/libcc1/compiler.hh
@@ -58,7 +58,7 @@  namespace cc1_plugin
 
     char *find (const char *base, std::string &compiler) const override;
 
-    compiler_triplet_regexp (bool v, std::string triplet_regexp)
+    compiler_triplet_regexp (bool v, const char *triplet_regexp)
       : compiler (v), triplet_regexp_ (triplet_regexp)
     {
     }
@@ -72,7 +72,7 @@  namespace cc1_plugin
   public:
     char *find (const char *base, std::string &compiler) const override;
 
-    compiler_driver_filename (bool v, std::string driver_filename)
+    compiler_driver_filename (bool v, const char *driver_filename)
       : compiler (v), driver_filename_ (driver_filename)
     {
     }