Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.cc

    r1cb7fab2 red34540  
    2626#include "Common/SemanticError.h"  // for SemanticError
    2727#include "Common/utility.h"        // for cloneAll
    28 #include "Common/Stats/Counter.h" // for counters
    2928#include "GenPoly/GenPoly.h"
    3029#include "InitTweak/InitTweak.h"   // for isConstructor, isCopyFunction, isC...
     
    4241
    4342namespace SymTab {
    44 
    45         // Statistics block
    46         namespace {
    47 
    48                 static inline auto stats_idtable() {
    49                         using namespace Stats::Counters;
    50                         static auto group = build<CounterGroup>("IdTable");
    51                         static struct {
    52                                 SimpleCounter * find;
    53                                 AverageCounter<double> * size;
    54                                 AverageCounter<double> * key;
    55                         } ret = {
    56                                 .find = build<SimpleCounter>("Find calls", group),
    57                                 .size = build<AverageCounter<double>>("Average Size", group),
    58                                 .key  = build<AverageCounter<double>>("Average Key Size", group),
    59                         };
    60                         return ret;
    61                 }
    62 
    63                 static inline auto stats_indexers() {
    64                         using namespace Stats::Counters;
    65                         static auto group   = build<CounterGroup>("Indexers");
    66                         static struct {
    67                                 SimpleCounter * count;
    68                                 AverageCounter<double> * size;
    69                                 AverageCounter<double> * depth_a;
    70                                 MaxCounter<size_t> * depth_m;
    71                         } ret = {
    72                                 .count   = build<SimpleCounter>("Count", group),
    73                                 .size    = build<AverageCounter<double>>("Average Size", group),
    74                                 .depth_a = build<AverageCounter<double>>("Average Depth", group),
    75                                 .depth_m = build<MaxCounter<size_t>>("Max Depth", group),
    76                         };
    77                         return ret;
    78                 }
    79         }
    80 
    8143        std::ostream & operator<<( std::ostream & out, const Indexer::IdData & data ) {
    8244                return out << "(" << data.id << "," << data.baseExpr << ")";
     
    235197        }
    236198
    237         Indexer::Indexer() : tables( 0 ), scope( 0 ) {
    238                 (*stats_indexers().count)++;
    239         }
    240 
    241         Indexer::Indexer( const Indexer &that ) : doDebug( that.doDebug ), tables( newRef( that.tables ) ), scope( that.scope ) {
    242                 (*stats_indexers().count)++;
    243         }
     199        Indexer::Indexer() : tables( 0 ), scope( 0 ) {}
     200
     201        Indexer::Indexer( const Indexer &that ) : doDebug( that.doDebug ), tables( newRef( that.tables ) ), scope( that.scope ) {}
    244202
    245203        Indexer::Indexer( Indexer &&that ) : doDebug( that.doDebug ), tables( that.tables ), scope( that.scope ) {
     
    248206
    249207        Indexer::~Indexer() {
    250                 if(tables) {
    251                         stats_indexers().size->push( tables->idTable.size() );
    252                         size_t depth = 1;
    253                         for( auto crnt = tables->base.tables; crnt; crnt = crnt->base.tables ) {
    254                                 ++depth;
    255                         }
    256                         stats_indexers().depth_a->push( depth );
    257                         stats_indexers().depth_m->push( depth );
    258                 }
    259208                deleteRef( tables );
    260209        }
     
    288237                while ( searchTables ) {
    289238
    290                         (*stats_idtable().find)++;
    291                         stats_idtable().key->push( id.size() );
    292                         stats_idtable().size->push( searchTables->idTable.size() );
    293239                        IdTable::const_iterator decls = searchTables->idTable.find( id );
    294240                        if ( decls != searchTables->idTable.end() ) {
     
    367313                if ( tables->scope < scope ) return nullptr;
    368314
    369                 (*stats_idtable().find)++;
    370                 stats_idtable().key->push( id.size() );
    371                 stats_idtable().size->push( tables->idTable.size() );
    372315                IdTable::const_iterator decls = tables->idTable.find( id );
    373316                if ( decls != tables->idTable.end() ) {
     
    388331                if ( tables->scope < scope ) return false;
    389332
    390                 (*stats_idtable().find)++;
    391                 stats_idtable().key->push( id.size() );
    392                 stats_idtable().size->push( tables->idTable.size() );
    393333                IdTable::const_iterator decls = tables->idTable.find( id );
    394334                if ( decls != tables->idTable.end() ) {
     
    407347                if ( tables->scope < scope ) return false;
    408348
    409                 (*stats_idtable().find)++;
    410                 stats_idtable().key->push( id.size() );
    411                 stats_idtable().size->push( tables->idTable.size() );
    412349                IdTable::const_iterator decls = tables->idTable.find( id );
    413350                if ( decls != tables->idTable.end() ) {
Note: See TracChangeset for help on using the changeset viewer.