]> sigrok.org Git - pulseview.git/commitdiff
View: Simplified get_traces
authorJoel Holdsworth <redacted>
Mon, 1 Sep 2014 20:56:56 +0000 (21:56 +0100)
committerJoel Holdsworth <redacted>
Wed, 19 Nov 2014 10:23:01 +0000 (10:23 +0000)
pv/view/view.cpp

index 305031ebd466c9a0b699e4641fa8b6639b8c5e5c..388c4c49ec75e00f35fac366366bef960823a87c 100644 (file)
@@ -43,6 +43,7 @@
 #include "pv/data/logicsnapshot.h"
 
 using pv::data::SignalData;
+using std::back_inserter;
 using std::deque;
 using std::list;
 using std::max;
@@ -242,21 +243,16 @@ void View::set_scale_offset(double scale, double offset)
 
 vector< shared_ptr<Trace> > View::get_traces() const
 {
+       vector< shared_ptr<Trace> > traces;
+
        const vector< shared_ptr<Signal> > sigs(
                session().get_signals());
+       copy(sigs.begin(), sigs.end(), back_inserter(traces));
+
 #ifdef ENABLE_DECODE
        const vector< shared_ptr<DecodeTrace> > decode_sigs(
                session().get_decode_signals());
-       vector< shared_ptr<Trace> > traces(
-               sigs.size() + decode_sigs.size());
-#else
-       vector< shared_ptr<Trace> > traces(sigs.size());
-#endif
-
-       auto i = traces.begin();
-       i = copy(sigs.begin(), sigs.end(), i);
-#ifdef ENABLE_DECODE
-       i = copy(decode_sigs.begin(), decode_sigs.end(), i);
+       copy(decode_sigs.begin(), decode_sigs.end(), back_inserter(traces));
 #endif
 
        stable_sort(traces.begin(), traces.end(),