Changeset 661e7b0 for src


Ignore:
Timestamp:
Aug 13, 2024, 11:54:04 AM (24 hours ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
2870cb6
Parents:
4941716
Message:

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.

Location:
src
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cpp

    r4941716 r661e7b0  
    7979                currentLocation.first_line += 2;
    8080        } else {
    81                 output << "\n# " << to.first_line << " \"" << to.filename
     81                output << "\n# " << to.first_line << " \"" << to.filename.c_str()
    8282                       << "\"\n" << indent;
    8383                currentLocation = to;
  • src/Common/CodeLocation.hpp

    r4941716 r661e7b0  
    1717
    1818#include <iostream>
    19 #include <string>
     19#include "Symbol.hpp"
    2020
    2121struct CodeLocation {
    2222        int first_line = -1, first_column = -1, last_line = -1, last_column = -1;
    23         std::string filename = "";
     23        Symbol filename = "";
    2424
    2525        /// Create a new unset CodeLocation.
     
    4646
    4747        bool startsBefore( CodeLocation const & other ) const {
    48                 if( filename < other.filename ) return true;
    49                 if( filename > other.filename ) return false;
     48                if( filename.str() < other.filename.str() ) return true;
     49                if( filename.str() > other.filename.str() ) return false;
    5050
    5151                if( first_line < other.first_line ) return true;
     
    7272inline std::ostream & operator<<( std::ostream & out, const CodeLocation & location ) {
    7373        // Column number ":1" allows IDEs to parse the error message and position the cursor in the source text.
    74         return location.isSet() ? out << location.filename << ":" << location.first_line << ":1 " : out;
     74        return location.isSet() ? out << location.filename.str() << ":" << location.first_line << ":1 " : out;
    7575}
  • src/Common/module.mk

    r4941716 r661e7b0  
    4848        Common/Stats/Time.cpp \
    4949        Common/Stats/Time.hpp \
     50        Common/Symbol.cpp \
     51        Common/Symbol.hpp \
    5052        Common/ToString.hpp \
    5153        Common/UniqueName.cpp \
  • src/InitTweak/FixInit.cpp

    r4941716 r661e7b0  
    731731        try {
    732732                mutLast->expr = makeCtorDtor( "?{}", ret, mutLast->expr );
    733         } catch(...) {
     733        } catch (...) {
    734734                std::cerr << "*CFA internal error: ";
    735735                std::cerr << "can't resolve implicit constructor";
    736                 std::cerr << " at " << stmtExpr->location.filename;
     736                std::cerr << " at " << stmtExpr->location.filename.c_str();
    737737                std::cerr << ":" << stmtExpr->location.first_line << std::endl;
    738738
Note: See TracChangeset for help on using the changeset viewer.