From 7a96a78fb12b3da0d9bf133cbecaeeabc2f459b5 Mon Sep 17 00:00:00 2001 From: pjrm Date: Fri, 4 Jul 2008 04:56:42 +0000 Subject: [PATCH] Poly::shifted: simplify to discard mention of handling negative argument value. --- src/2geom/poly.cpp | 1 - src/2geom/poly.h | 29 ++++++++--------------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/2geom/poly.cpp b/src/2geom/poly.cpp index 5f7663957..1b9b0e568 100644 --- a/src/2geom/poly.cpp +++ b/src/2geom/poly.cpp @@ -151,7 +151,6 @@ Poly divide(Poly const &a, Poly const &b, Poly &r) { c.resize(k, 0.); for(unsigned i = k; i >= l; i--) { - assert(i >= 0); double ci = r.back()/b.back(); c[i-l] += ci; Poly bb = ci*b; diff --git a/src/2geom/poly.h b/src/2geom/poly.h index f76bc3eee..2d7b79bfe 100644 --- a/src/2geom/poly.h +++ b/src/2geom/poly.h @@ -92,33 +92,20 @@ public: assert(result.size() == out_size); return result; } -// equivalent to multiply by x^terms, discard negative terms - Poly shifted(unsigned terms) const { + + /** Equivalent to multiply by x^terms. */ + Poly shifted(unsigned const terms) const { Poly result; - // This was a no-op and breaks the build on x86_64, as it's trying - // to take maximum of 32-bit and 64-bit integers - //const unsigned out_size = std::max(unsigned(0), size()+terms); - const size_type out_size = size() + terms; + size_type const out_size = size() + terms; result.reserve(out_size); -// By definition an unsigned can not be less than zero -// TODO someone who understands the intent needs to correct this properly -// if(terms < 0) { -// for(unsigned i = 0; i < out_size; i++) { -// result.push_back((*this)[i-terms]); -// } -// } else { - for(unsigned i = 0; i < terms; i++) { - result.push_back(0.0); - } - for(unsigned i = 0; i < size(); i++) { - result.push_back((*this)[i]); - } -// } - + result.resize(terms, 0.0); + result.insert(result.end(), this->begin(), this->end()); + assert(result.size() == out_size); return result; } + Poly operator*(const Poly& p) const; template -- 2.30.2