]> sourceware.org Git - systemtap.git/commitdiff
string_ref cont'd, considering token::msg
authorFrank Ch. Eigler <fche@redhat.com>
Fri, 7 Aug 2015 19:43:14 +0000 (15:43 -0400)
committerAbegail Jakop <ajakop@redhat.com>
Tue, 18 Aug 2015 17:24:15 +0000 (13:24 -0400)
Experimentation indicates that the sizeof(interned_string)=24
is so much larger than that of an empty sizeof(std::string)=8
that for mostly-empty slots it's a loss!  A 1-byte std::string
causes a 26-byte malloc, so the interned_string is probably
good for nonempty strings.

parse.cxx
parse.h

index 94ea5eb0ff23711331af25017b0ab157d43c6a6f..c092f80d344a2402f5103189ce900f0ccab39bd8 100644 (file)
--- a/parse.cxx
+++ b/parse.cxx
@@ -1830,7 +1830,7 @@ skip:
 // ------------------------------------------------------------------------
 
 void
-token::make_junk (const string new_msg)
+token::make_junk (const string& new_msg)
 {
   type = tok_junk;
   msg = new_msg;
diff --git a/parse.h b/parse.h
index 480288e02e85d8e34444886eff40ed4f66aa47d5..573ea86b35163b38c5ce972c886628645d5f8cf3 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -48,18 +48,19 @@ enum token_type
 struct token
 {
   source_loc location;
-  token_type type;
   interned_string content;
-  std::string msg; // for tok_junk
-  void make_junk (const std::string msg);
+  std::string msg; // for tok_junk, more efficient than interned_string if empty
   const token* chain; // macro invocation that produced this token
+  token_type type;
+  
+  void make_junk (const std::string& msg);
   friend class parser;
   friend class lexer;
 private:
-  token(): type(tok_junk), chain(0) {}
+  token(): chain(0), type(tok_junk) {}
   token(const token& other):
-    location(other.location), type(other.type), content(other.content),
-    msg(other.msg), chain(other.chain) {}
+    location(other.location), content(other.content),
+    msg(other.msg), chain(other.chain), type(other.type) {}
 };
 
 
This page took 0.032388 seconds and 5 git commands to generate.