Skip to content

Commit 01c84ac

Browse files
committed
Small fixes
1 parent 0a30909 commit 01c84ac

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

include/phasar/Utils/Utilities.h

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,36 @@ It remove_by_index(It First, EndIt Last, IdxIt FirstIndex, IdxEndIt LastIndex) {
203203

204204
auto CurrIdx = *FirstIndex;
205205

206-
/// TODO: Optimize this loop
206+
if constexpr (std::is_same_v<It, EndIt> &&
207+
std::is_same_v<
208+
std::random_access_iterator_tag,
209+
typename std::iterator_traits<It>::iterator_category>) {
210+
size_t GapSize = 1;
211+
auto Curr = First + 1;
212+
213+
while (++FirstIndex != LastIndex) {
214+
auto Offset = *FirstIndex - CurrIdx - 1;
215+
if (Offset >= std::distance(Curr, Last)) {
216+
break;
217+
}
218+
First = std::move(Curr, Curr + Offset, First);
219+
CurrIdx = *FirstIndex;
220+
Curr = First + ++GapSize;
221+
}
207222

208-
for (auto I = First; ++I != Last; ++CurrIdx) {
209-
if (FirstIndex == LastIndex || CurrIdx != *FirstIndex) {
210-
*First++ = std::move(*I);
211-
if (FirstIndex != LastIndex) {
212-
++FirstIndex;
223+
return std::move(Curr, Last, First);
224+
} else {
225+
226+
for (auto I = First; I != Last; ++CurrIdx, ++I) {
227+
if (CurrIdx != *FirstIndex) {
228+
*First++ = std::move(*I);
229+
if (++FirstIndex == LastIndex) {
230+
return std::move(std::next(I), Last, First);
231+
}
213232
}
214233
}
234+
return First;
215235
}
216-
return First;
217236
}
218237

219238
template <typename Container, typename IdxIt, typename IdxEndIt>

lib/PhasarLLVM/DataFlowSolver/IfdsIde/IFDSIDESolverConfig.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Philipp Schubert and others
88
*****************************************************************************/
99

10+
#include <ios>
1011
#include <ostream>
1112

1213
#include "phasar/PhasarLLVM/DataFlowSolver/IfdsIde/IFDSIDESolverConfig.h"
@@ -67,7 +68,7 @@ ostream &operator<<(ostream &OS, const IFDSIDESolverConfig &SC) {
6768
return OS << "IFDSIDESolverConfig:\n"
6869
<< "\tfollowReturnsPastSeeds: " << SC.followReturnsPastSeeds()
6970
<< "\n"
70-
<< "\tautoAddZero: " << SC.autoAddZero() << "\n"
71+
<< "\tautoAddZero: " << std::boolalpha << SC.autoAddZero() << "\n"
7172
<< "\tcomputeValues: " << SC.computeValues() << "\n"
7273
<< "\trecordEdges: " << SC.recordEdges() << "\n"
7374
<< "\tcomputePersistedSummaries: " << SC.computePersistedSummaries()

tools/phasar-llvm/phasar-llvm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
*****************************************************************************/
99

1010
#include <algorithm>
11-
#include <boost/program_options/value_semantic.hpp>
1211
#include <chrono>
1312
#include <set>
1413
#include <string>
1514
#include <vector>
1615

1716
#include "boost/filesystem.hpp"
1817
#include "boost/program_options.hpp"
18+
#include "boost/program_options/value_semantic.hpp"
1919

2020
#include "boost/dll.hpp"
2121
#include "boost/filesystem.hpp"

0 commit comments

Comments
 (0)