Changeset View
Changeset View
Standalone View
Standalone View
sheets/RectStorage.h
Show First 20 Lines • Show All 564 Lines • ▼ Show 20 Line(s) | |||||
565 | void RectStorageLoader<T>::run() | 565 | void RectStorageLoader<T>::run() | ||
566 | { | 566 | { | ||
567 | static int total = 0; | 567 | static int total = 0; | ||
568 | debugSheets << "Loading conditional styles"; | 568 | debugSheets << "Loading conditional styles"; | ||
569 | QTime t; t.start(); | 569 | QTime t; t.start(); | ||
570 | 570 | | |||
571 | QList<QPair<QRegion, T> > treeData; | 571 | QList<QPair<QRegion, T> > treeData; | ||
572 | typedef QPair<QRegion, T> TRegion; | 572 | typedef QPair<QRegion, T> TRegion; | ||
573 | QMap<T, int> indexCache; | | |||
574 | foreach (const TRegion& tr, m_data) { | 573 | foreach (const TRegion& tr, m_data) { | ||
575 | const QRegion& reg = tr.first; | 574 | const QRegion& reg = tr.first; | ||
576 | const T& d = tr.second; | 575 | const T& d = tr.second; | ||
577 | 576 | | |||
578 | typename QMap<T, int>::iterator idx = indexCache.find(d); | 577 | int index = m_storage->m_storedData.indexOf(d); | ||
579 | int index = idx != indexCache.end() ? idx.value() : m_storage->m_storedData.indexOf(d); | | |||
580 | if (index != -1) { | 578 | if (index != -1) { | ||
581 | treeData.append(qMakePair(reg, m_storage->m_storedData[index])); | 579 | treeData.append(qMakePair(reg, m_storage->m_storedData[index])); | ||
582 | if (idx == indexCache.end()) indexCache.insert(d, index); | | |||
583 | } else { | 580 | } else { | ||
584 | treeData.append(tr); | 581 | treeData.append(tr); | ||
585 | if (idx == indexCache.end()) indexCache.insert(d, m_storage->m_storedData.size()); | | |||
586 | m_storage->m_storedData.append(d); | 582 | m_storage->m_storedData.append(d); | ||
587 | } | 583 | } | ||
588 | } | 584 | } | ||
589 | 585 | | |||
590 | m_storage->m_tree.load(treeData); | 586 | m_storage->m_tree.load(treeData); | ||
591 | int e = t.elapsed(); | 587 | int e = t.elapsed(); | ||
592 | total += e; | 588 | total += e; | ||
593 | debugSheets << "Time: " << e << total; | 589 | debugSheets << "Time: " << e << total; | ||
▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines |