Skip to content

Commit 08113f2

Browse files
author
Benno Evers
committedOct 22, 2014
Switch to two-phase lookup
1 parent 61880f7 commit 08113f2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎matplotlibcpp.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,19 @@ namespace matplotlibcpp {
315315
bool operator()(const IterableX& x, const IterableY& y, const std::string& format)
316316
{
317317
// It's annoying that we have to repeat the code of plot() above
318-
auto xs = std::distance(std::begin(x), std::end(x));
319-
auto ys = std::distance(std::begin(y), std::end(y));
318+
using std::distance;
319+
using std::begin;
320+
using std::end;
321+
322+
auto xs = distance(begin(x), end(x));
323+
auto ys = distance(begin(y), end(y));
320324
assert(xs == ys && "x and y data must have the same number of elements!");
321325

322326
PyObject* xlist = PyList_New(xs);
323327
PyObject* ylist = PyList_New(ys);
324328
PyObject* pystring = PyString_FromString(format.c_str());
325329

326-
auto itx = std::begin(x), ity = std::begin(y);
330+
auto itx = begin(x), ity = begin(y);
327331
for(size_t i = 0; i < xs; ++i) {
328332
PyList_SetItem(xlist, i, PyFloat_FromDouble(*itx++));
329333
PyList_SetItem(ylist, i, PyFloat_FromDouble(*ity++));

0 commit comments

Comments
 (0)
Please sign in to comment.