source: src/Common/Symbol.hpp @ 4558df2

Last change on this file since 4558df2 was 661e7b0, checked in by Andrew Beach <ajbeach@…>, 2 weeks ago

After a years (or at least half a year) the CodeLocation? optimization is merged in. Added Symbol (using Racket's name for interned strings), and used it for CodeLocation? file names. The optimizes for the high number of copies - both instances with the same value and copy operations - and consistently brings down runtime by a few percent.

  • Property mode set to 100644
File size: 651 bytes
Line 
1#pragma once
2
3#include <string>
4
5// Internal Type:
6class SymbolData;
7
8/// A Symbol is an interned string, where the characters are 'hidden'.
9class Symbol final {
10        SymbolData * data;
11public:
12        /// Create a Symbol for the empty string.
13        Symbol();
14
15        Symbol(std::string const &);
16        Symbol(char const *);
17        Symbol(Symbol const &);
18        Symbol(Symbol &&);
19
20        ~Symbol();
21
22        Symbol & operator=(std::string const &);
23        Symbol & operator=(char const *);
24        Symbol & operator=(Symbol const &);
25        Symbol & operator=(Symbol &&);
26
27        bool operator==(Symbol const &) const;
28        bool operator!=(Symbol const &) const;
29
30        std::string const & str() const;
31        char const * c_str() const;
32};
Note: See TracBrowser for help on using the repository browser.