[matplotlib/plot_store.cpp] Removed useless function

checkFloatType function used to check for an obj type before cast. This is already done by mp_obj_get_float

Change-Id: I745bb3066328678ab0b2a2149c8f38a84f26fbd2
This commit is contained in:
Arthur Camouseigt
2020-05-25 17:18:17 +02:00
committed by Émilie Feral
parent 68ff71f72a
commit 985c31920d

View File

@@ -56,15 +56,6 @@ T PlotStore::ListIterator<T>::operator*() {
return T(m_tuples[m_tupleIndex]);
};
void checkFloatType(mp_obj_t * elements, size_t nbOfElements) {
for (size_t i = 0; i < nbOfElements; i++) {
// TODO: we don't take advantage of the fact that we extracted the value at the sametime... Maybe change the way things are done, build the c objects in addItem instead of allocating them on the python heap? Or use float array in python?
mp_float_t value;
if (!mp_obj_get_float_maybe(elements[i], &value)) {
mp_raise_TypeError("argument should be a number");
}
}
}
// Dot
@@ -81,7 +72,6 @@ PlotStore::Dot::Dot(mp_obj_t tuple) {
void PlotStore::addDot(mp_obj_t x, mp_obj_t y, KDColor c) {
mp_obj_t color = mp_obj_new_int(c);
mp_obj_t items[3] = {x, y, color};
checkFloatType(items, 2);
mp_obj_t tuple = mp_obj_new_tuple(3, items);
mp_obj_list_append(m_dots, tuple);
}
@@ -104,7 +94,6 @@ PlotStore::Segment::Segment(mp_obj_t tuple) {
void PlotStore::addSegment(mp_obj_t xStart, mp_obj_t yStart, mp_obj_t xEnd, mp_obj_t yEnd, KDColor c, mp_obj_t arrowWidth) {
mp_obj_t color = mp_obj_new_int(c);
mp_obj_t items[6] = {xStart, yStart, xEnd, yEnd, arrowWidth, color};
checkFloatType(items, 5);
mp_obj_t tuple = mp_obj_new_tuple(6, items);
mp_obj_list_append(m_segments, tuple);
}
@@ -126,7 +115,6 @@ PlotStore::Rect::Rect(mp_obj_t tuple) {
void PlotStore::addRect(mp_obj_t left, mp_obj_t right, mp_obj_t top, mp_obj_t bottom, KDColor c) {
mp_obj_t color = mp_obj_new_int(c);
mp_obj_t items[5] = {left, right, top, bottom, color};
checkFloatType(items, 4);
mp_obj_t tuple = mp_obj_new_tuple(5, items);
mp_obj_list_append(m_rects, tuple);
}
@@ -145,7 +133,6 @@ PlotStore::Label::Label(mp_obj_t tuple) {
void PlotStore::addLabel(mp_obj_t x, mp_obj_t y, mp_obj_t string) {
mp_obj_t items[3] = {x, y, string};
checkFloatType(items, 2);
if (!mp_obj_is_str(string)) {
mp_raise_TypeError("argument should be a string");
}