Ignore:
Timestamp:
Jan 23, 2013, 9:36:03 PM (8 years ago)
Author:
sam
Message:

base: optimise array concatenation, fix string concatenation, and fix
string concatenation unit tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lol/base/array.h

    r2267 r2269  
    9696    }
    9797
    98     ArrayBase& operator+=(ARRAY const &that)
     98    ArrayBase& operator+=(ArrayBase const &that)
    9999    {
    100100        int todo = that.m_count;
    101101        Reserve(m_count + that.m_count);
    102102        for (int i = 0; i < todo; i++)
    103             *this << that[i];
     103            new(&m_data[m_count + i]) Element(that[i]);
     104        m_count += todo;
    104105        return *this;
    105106    }
     
    107108    ARRAY operator+(ARRAY const &that) const
    108109    {
    109         /* FIXME: upon return, this makes a copy of the temporary object;
    110          * use either C++11 move semantics, or add a special flag to the
    111          * object indicating we're a temporary about to be destroyed */
    112110        ARRAY ret;
    113111        ret.Reserve(m_count + that.m_count);
    114         for (int i = 0; i < m_count; i++)
    115             ret << (*this)[i];
    116         for (int i = 0; i < that.m_count; i++)
    117             ret << that[i];
     112        ret += *this;
     113        ret += that;
    118114        return ret;
    119115    }
Note: See TracChangeset for help on using the changeset viewer.