Skip to content

Commit 6ceeb9a

Browse files
committed
optimize createCluster
1 parent c7cd590 commit 6ceeb9a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/gencore.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,23 @@ void Gencore::addToUnProperCluster(bam1_t* b) {
295295
}
296296

297297
void Gencore::createCluster(map<int, map<int, map<int, Cluster*>>>& clusters, int tid, int left, int right) {
298-
if(clusters.count(tid) == 0)
298+
map<int, map<int, map<int, Cluster*>>>::iterator iter1 = clusters.find(tid);
299+
300+
if(iter1 == clusters.end()) {
299301
clusters[tid] = map<int, map<int, Cluster*>>();
300-
if(clusters[tid].count(left) == 0)
301302
clusters[tid][left] = map<int, Cluster*>();
302-
if(clusters[tid][left].count(right) == 0)
303303
clusters[tid][left][right] = new Cluster(mOptions);
304+
} else {
305+
map<int, map<int, Cluster*>>::iterator iter2 =iter1->second.find(left);
306+
if(iter2 == iter1->second.end()) {
307+
clusters[tid][left] = map<int, Cluster*>();
308+
clusters[tid][left][right] = new Cluster(mOptions);
309+
} else {
310+
map<int, Cluster*>::iterator iter3 = iter2->second.find(right);
311+
if(iter3 == iter2->second.end())
312+
clusters[tid][left][right] = new Cluster(mOptions);
313+
}
314+
}
304315
}
305316

306317
void Gencore::addToCluster(bam1_t* b) {

0 commit comments

Comments
 (0)