Ignore:
Timestamp:
Dec 3, 2017, 12:40:40 PM (16 months ago)
Author:
nmedfort
Message:

Bug fixes and simplified MultiBlockKernel? logic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/unicode_set.cpp

    r5750 r5755  
    185185            const auto m = lengthOf(r) * QUAD_BITS;
    186186            if (LLVM_UNLIKELY(remaining < m)) {
    187                 return base + remaining;
     187                return (base * QUAD_BITS) + remaining;
    188188            }
    189189            base += m;
    190             remaining -= m;
     190            remaining -= m * QUAD_BITS;
    191191        } else { // if (typeOf(r) == Mixed) {
    192192            for (auto l = lengthOf(r); l; --l, ++qi) {
     
    199199                        const bitquad_t k = scan_forward_zeroes<bitquad_t>(q);
    200200                        if (remaining == 0) {
    201                             return base + k;
     201                            return (base * QUAD_BITS) + k;
    202202                        }
    203203                        q ^= static_cast<bitquad_t>(1) << k;
     
    205205                    }
    206206                }
    207                 base += QUAD_BITS;
     207                ++base;
    208208                remaining -= c;
    209209            }
     
    14121412 ** ------------------------------------------------------------------------------------------------------------- */
    14131413UnicodeSet::UnicodeSet(const UnicodeSet & other) noexcept
    1414 : mRuns(other.mRuns)
    1415 , mQuads(other.mQuads)
    1416 , mRunLength(other.mRunLength)
    1417 , mQuadLength(other.mQuadLength)
    1418 , mRunCapacity(0) // lazily ensure reallocation on modification
     1414: mRuns(nullptr)
     1415, mQuads(nullptr)
     1416, mRunLength(0)
     1417, mQuadLength(0)
     1418, mRunCapacity(0)
    14191419, mQuadCapacity(0) {
     1420    // lazily ensure reallocation on modification if and only if the source cannot modify it
     1421    if (other.mRunCapacity == 0) {
     1422        mRuns = other.mRuns;
     1423        mRunCapacity = 0;
     1424    } else {
     1425        mRuns = copyOf<run_t>(other.mRuns, other.mRunLength, GlobalAllocator);
     1426        mRunCapacity = other.mRunLength;
     1427    }
     1428    mRunLength = other.mRunLength;
     1429    if (other.mQuadCapacity == 0) {
     1430        mQuads = other.mQuads;
     1431        mQuadCapacity = 0;
     1432    } else {
     1433        mQuads = copyOf<bitquad_t>(other.mQuads, other.mQuadCapacity, GlobalAllocator);
     1434        mQuadCapacity = other.mQuadLength;
     1435    }
     1436    mQuadLength = other.mQuadLength;
    14201437    assert (verify(mRuns, other.mRunLength, mQuads, other.mQuadLength));
    14211438}
     
    14311448        GlobalAllocator.deallocate<bitquad_t>(mQuads, mQuadCapacity);
    14321449    }
    1433     mRuns = other.mRuns;
    1434     mQuads = other.mQuads;
     1450    // lazily ensure reallocation on modification if and only if the source cannot modify it
     1451    if (other.mRunCapacity == 0) {
     1452        mRuns = other.mRuns;
     1453        mRunCapacity = 0;
     1454    } else {
     1455        mRuns = copyOf<run_t>(other.mRuns, other.mRunLength, GlobalAllocator);
     1456        mRunCapacity = other.mRunLength;
     1457    }
    14351458    mRunLength = other.mRunLength;
     1459    if (other.mQuadCapacity == 0) {
     1460        mQuads = other.mQuads;
     1461        mQuadCapacity = 0;
     1462    } else {
     1463        mQuads = copyOf<bitquad_t>(other.mQuads, other.mQuadCapacity, GlobalAllocator);
     1464        mQuadCapacity = other.mQuadLength;
     1465    }
    14361466    mQuadLength = other.mQuadLength;
    1437     mRunCapacity = 0; // lazily ensure reallocation on modification
    1438     mQuadCapacity = 0;
    14391467    assert (verify(mRuns, mRunLength, mQuads, mQuadLength));
    14401468    return *this;
Note: See TracChangeset for help on using the changeset viewer.