Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e55d11e1 authored by Leon Scroggins III's avatar Leon Scroggins III Committed by Leon Scroggins
Browse files

Remove Flattener::mLayersHash

Bug:163076219
Test: make

This field is computed and then immediately returned by another method.
But it is never read again until it has been rewritten. The client of
Flattener::flattenLayers stores the value, but this class doesn't need
to store it, too. Remove the field, and switch updateLayersHash to
computeLayersHash, which simply computes and returns the value. This is
simpler and clearer.

Change-Id: I065f1968bbe66e94180c57c54ba4f32a3a8ddf40
parent 219aba11
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -54,7 +54,7 @@ private:


    void resetActivities(NonBufferHash, std::chrono::steady_clock::time_point now);
    void resetActivities(NonBufferHash, std::chrono::steady_clock::time_point now);


    void updateLayersHash();
    NonBufferHash computeLayersHash() const;


    bool mergeWithCachedSets(const std::vector<const LayerState*>& layers,
    bool mergeWithCachedSets(const std::vector<const LayerState*>& layers,
                             std::chrono::steady_clock::time_point now);
                             std::chrono::steady_clock::time_point now);
@@ -69,7 +69,6 @@ private:
    std::chrono::steady_clock::time_point mLastGeometryUpdate;
    std::chrono::steady_clock::time_point mLastGeometryUpdate;


    std::vector<CachedSet> mLayers;
    std::vector<CachedSet> mLayers;
    NonBufferHash mLayersHash = 0;
    std::optional<CachedSet> mNewCachedSet;
    std::optional<CachedSet> mNewCachedSet;


    // Statistics
    // Statistics
+3 −4
Original line number Original line Diff line number Diff line
@@ -41,7 +41,7 @@ NonBufferHash Flattener::flattenLayers(const std::vector<const LayerState*>& lay
    ++mInitialLayerCounts[layers.size()];
    ++mInitialLayerCounts[layers.size()];


    if (mergeWithCachedSets(layers, now)) {
    if (mergeWithCachedSets(layers, now)) {
        hash = mLayersHash;
        hash = computeLayersHash();
    }
    }


    ++mFinalLayerCounts[mLayers.size()];
    ++mFinalLayerCounts[mLayers.size()];
@@ -169,12 +169,12 @@ void Flattener::resetActivities(NonBufferHash hash, time_point now) {
    }
    }
}
}


void Flattener::updateLayersHash() {
NonBufferHash Flattener::computeLayersHash() const{
    size_t hash = 0;
    size_t hash = 0;
    for (const auto& layer : mLayers) {
    for (const auto& layer : mLayers) {
        android::hashCombineSingleHashed(hash, layer.getNonBufferHash());
        android::hashCombineSingleHashed(hash, layer.getNonBufferHash());
    }
    }
    mLayersHash = hash;
    return hash;
}
}


bool Flattener::mergeWithCachedSets(const std::vector<const LayerState*>& layers, time_point now) {
bool Flattener::mergeWithCachedSets(const std::vector<const LayerState*>& layers, time_point now) {
@@ -280,7 +280,6 @@ bool Flattener::mergeWithCachedSets(const std::vector<const LayerState*>& layers
    }
    }


    mLayers = std::move(merged);
    mLayers = std::move(merged);
    updateLayersHash();
    return true;
    return true;
}
}