Changeset 736 in dev


Ignore:
Timestamp:
Aug 25, 2008, 5:38:29 PM (16 years ago)
Author:
イグトランス (egtra)
Message:

Symbol周りを高速化

Location:
trunk/ab5.0/abdev
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler_Common/StrOperation.cpp

    r727 r736  
    391391            if( esc == ESC_OPERATOR )
    392392            {
    393                 extern char *calcNames[256];
     393                extern char const *calcNames[256];
    394394                unsigned char calcId = temporary[i+2];
    395395                if( calcNames[calcId] )
  • trunk/ab5.0/abdev/ab_common/src/Lexical/Namespace.cpp

    r700 r736  
    11#include "stdafx.h"
    2 
     2#include <algorithm>
    33
    44using namespace ActiveBasic::Common::Lexical;
     
    2828NamespaceScopes NamespaceScopes::operator+ ( const NamespaceScopes &namespaceScopes ) const
    2929{
    30     NamespaceScopes result = *this;
    31     BOOST_FOREACH( const std::string &name, namespaceScopes )
    32     {
    33         result.push_back( name );
    34     }
     30    NamespaceScopes result;
     31    result.reserve( this->size() + namespaceScopes.size() );
     32    result = *this;
     33    result.append( namespaceScopes );
    3534    return result;
    3635}
     
    4241        return false;
    4342    }
    44 
    45     for( int i=static_cast<int>(this->size()-1); i>=0; i-- )
    46     {
    47         if( (*this)[i] != namespaceScopes[i] )
    48         {
    49             return false;
    50         }
    51     }
    52 
    53     return true;
     43    return std::equal(begin(), end(), namespaceScopes.begin() );
    5444}
    5545
  • trunk/ab5.0/abdev/ab_common/src/Lexical/NamespaceSupporter.cpp

    r670 r736  
    3131
    3232    // 現在の名前空間とのマッチングを試みる
    33     NamespaceScopes tempCurrent = this->livingNamespaceScopes;
    34     while( !tempCurrent.empty() )
     33    typedef NamespaceScopes::const_iterator cnsit_t;
     34    cnsit_t first = livingNamespaceScopes.begin();
     35    cnsit_t last = livingNamespaceScopes.end();
     36    NamespaceScopes temp;
     37    while( first != last )
    3538    {
    36         if( base.IsEqual( tempCurrent + entry ) )
     39        temp.assign( first, last );
     40        temp.append( entry );
     41        if( base.IsEqual( temp ) )
    3742        {
    3843            return true;
    3944        }
    40 
    41         tempCurrent.pop_back();
     45        --last;
    4246    }
    4347
  • trunk/ab5.0/abdev/ab_common/src/Lexical/Symbol.cpp

    r632 r736  
    55const NamespaceSupporter *Symbol::namespaceSupporter = NULL;
    66
    7 char *calcNames[256] = {
    8     "xor",
     7char const *calcNames[256] = {
     8    0,
    99};
    1010void InitCalcNames()
     
    1414        return;
    1515    }
    16 
    17     memset( calcNames, 0, 255 * sizeof(char *) );
    1816    calcNames[CALC_XOR] = "xor";
    1917    calcNames[CALC_OR] = "or";
     
    106104    if( namespaceScopes.size() )
    107105    {
    108         return namespaceScopes.ToString() + "." + name;
     106        return namespaceScopes.ToString() + '.' + name;
    109107    }
    110108
     
    123121bool Symbol::IsEqualSymbol( const Symbol &symbol ) const
    124122{
    125     if( IsEqualSymbol( symbol.GetNamespaceScopes(), symbol.GetName() ) )
     123    const NamespaceScopes &symbolNS = symbol.GetNamespaceScopes();
     124    if( IsEqualSymbol( symbolNS, symbol.GetName() ) )
    126125    {
    127126        return true;
    128127    }
    129128
    130     if( symbol.GetNamespaceScopes().size() >= 1 )
     129    if( !symbolNS.empty() )
    131130    {
    132131        // 静的メンバを考慮
    133         NamespaceScopes namespaceScopes( symbol.GetNamespaceScopes() );
    134         std::string name = namespaceScopes[namespaceScopes.size()-1] + "." + symbol.GetName();
    135         namespaceScopes.pop_back();
    136 
    137         return IsEqualSymbol( namespaceScopes, name );
     132        std::string name = symbolNS.back() + '.' + symbol.GetName();
     133        if( GetName() != name ){
     134            return false;
     135        }
     136        return IsEqualSymbol( NamespaceScopes( symbolNS.begin(), symbolNS.end() - 1 ), name );
    138137    }
    139138    return false;
Note: See TracChangeset for help on using the changeset viewer.