Paste P132

Masterwork From Distant Lands
ActivePublic

Authored by dkazakov on Nov 7 2017, 9:45 AM.
diff --git a/libs/image/tiles3/kis_tile_data_store.cc b/libs/image/tiles3/kis_tile_data_store.cc
index a541b6c..aedb97e 100644
--- a/libs/image/tiles3/kis_tile_data_store.cc
+++ b/libs/image/tiles3/kis_tile_data_store.cc
@@ -119,6 +119,8 @@ KisTileDataStore::MemoryStatistics KisTileDataStore::memoryStatistics()
return stats;
}
+static KisLocklessStack<KisTileData*> reusedDataObjects;
+
inline void KisTileDataStore::registerTileDataImp(KisTileData *td)
{
td->m_listIterator = m_tileDataList.insert(m_tileDataList.end(), td);
@@ -163,23 +165,36 @@ KisTileData *KisTileDataStore::duplicateTileData(KisTileData *rhs)
{
KisTileData *td = 0;
- if (rhs->m_clonesStack.pop(td)) {
- DEBUG_PRECLONE_ACTION("+ Pre-clone HIT", rhs, td);
- DEBUG_COUNT_PRECLONE_HIT(rhs);
- } else {
+ if (reusedDataObjects.pop(td)) {
rhs->blockSwapping();
- td = new KisTileData(*rhs);
+ td->setData(rhs->data());
rhs->unblockSwapping();
- DEBUG_PRECLONE_ACTION("- Pre-clone #MISS#", rhs, td);
- DEBUG_COUNT_PRECLONE_MISS(rhs);
+ } else {
+ if (rhs->m_clonesStack.pop(td)) {
+ DEBUG_PRECLONE_ACTION("+ Pre-clone HIT", rhs, td);
+ DEBUG_COUNT_PRECLONE_HIT(rhs);
+ } else {
+ rhs->blockSwapping();
+ td = new KisTileData(*rhs);
+ rhs->unblockSwapping();
+ DEBUG_PRECLONE_ACTION("- Pre-clone #MISS#", rhs, td);
+ DEBUG_COUNT_PRECLONE_MISS(rhs);
+ }
+
+ registerTileData(td);
}
- registerTileData(td);
return td;
}
void KisTileDataStore::freeTileData(KisTileData *td)
{
+ if (reusedDataObjects.size() < 200) {
+ reusedDataObjects.push(td);
+ return;
+ }
+
+
Q_ASSERT(td->m_store == this);
DEBUG_FREE_ACTION(td);
diff --git a/libs/image/tiles3/kis_tile_hash_table_p.h b/libs/image/tiles3/kis_tile_hash_table_p.h
index 349a61d..80ca6fa 100644
--- a/libs/image/tiles3/kis_tile_hash_table_p.h
+++ b/libs/image/tiles3/kis_tile_hash_table_p.h
@@ -351,7 +351,6 @@ void KisTileHashTableTraits<T>::clear()
}
KIS_SAFE_ASSERT_RECOVER_NOOP(!numTilesToRemove);
- KIS_SAFE_ASSERT_RECOVER_NOOP(!m_numTiles);
}
template<class T>
dkazakov edited the content of this paste. (Show Details)Nov 7 2017, 9:45 AM
dkazakov changed the title of this paste from untitled to Masterwork From Distant Lands.
dkazakov updated the paste's language from autodetect to autodetect.