@@ -155,16 +155,28 @@ void GetShadowCopyLocations(const std::vector<Location::Ptr>& locations, ShadowC
155
155
}
156
156
}
157
157
158
+ // Use this function and a vector instead of std::set to keep original ordering
159
+ void UniquePushBack (const Orc::Location::Ptr & location, std::vector<Orc::Location::Ptr >& items)
160
+ {
161
+ auto it = std::find_if (
162
+ std::cbegin (items), std::cend (items), [&location](const auto & item) { return item.get () == location.get (); });
163
+
164
+ if (it == std::cend (items))
165
+ {
166
+ items.push_back (location);
167
+ }
168
+ };
169
+
158
170
void FilterLocations (
159
171
const std::vector<Location::Ptr >& locations,
160
172
const LocationSet::ShadowFilters& filters,
161
- std::set <Location::Ptr >& output)
173
+ std::vector <Location::Ptr >& output)
162
174
{
163
175
if (filters.empty ())
164
176
{
165
177
for (const auto & loc : locations)
166
178
{
167
- output. insert (loc);
179
+ UniquePushBack (loc, output );
168
180
}
169
181
170
182
return ;
@@ -179,17 +191,17 @@ void FilterLocations(
179
191
180
192
if (shadows.newest && filters.find (L" newest" ) != std::cend (filters))
181
193
{
182
- output. insert (shadows.newest );
194
+ UniquePushBack (shadows.newest , output );
183
195
}
184
196
185
197
if (shadows.mid && filters.find (L" mid" ) != std::cend (filters))
186
198
{
187
- output. insert (shadows.mid );
199
+ UniquePushBack (shadows.mid , output );
188
200
}
189
201
190
202
if (shadows.oldest && filters.find (L" oldest" ) != std::cend (filters))
191
203
{
192
- output. insert (shadows.oldest );
204
+ UniquePushBack (shadows.oldest , output );
193
205
}
194
206
195
207
for (const auto & filter : filters)
@@ -200,7 +212,7 @@ void FilterLocations(
200
212
auto it = shadows.guids .find (*guid);
201
213
if (it != std::cend (shadows.guids ))
202
214
{
203
- output. insert (it->second );
215
+ UniquePushBack (it->second , output );
204
216
}
205
217
}
206
218
}
@@ -2299,7 +2311,7 @@ HRESULT LocationSet::AltitudeLocations(
2299
2311
shadowCopiesLocations.push_back (std::move (vssLoc));
2300
2312
}
2301
2313
2302
- std::set <Location::Ptr > shadowsSelection;
2314
+ std::vector <Location::Ptr > shadowsSelection;
2303
2315
::FilterLocations (shadowCopiesLocations, shadowFilters, shadowsSelection);
2304
2316
2305
2317
for (const auto & loc : shadowsSelection)
0 commit comments