From: Alexei Sheplyakov Date: Mon, 25 Aug 2008 12:55:13 +0000 (+0400) Subject: gcd_pf_mul: get rid of duplicate code. X-Git-Tag: release_1-5-0~74 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=adb1dbd383ae6e5a999b5f8cba72a5c2bfd50c11;hp=c77689e7ac8d8f4dbca0f337b6e9acf2419010ff gcd_pf_mul: get rid of duplicate code. This function (which helps gcd() handle partially factored expressions) contained two copies of the same code. Remove one redundant copy. --- diff --git a/ginac/normal.cpp b/ginac/normal.cpp index 5d044fc6..2bb3a430 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -1746,45 +1746,29 @@ static ex gcd_pf_pow(const ex& a, const ex& b, ex* ca, ex* cb, bool check_args) static ex gcd_pf_mul(const ex& a, const ex& b, ex* ca, ex* cb, bool check_args) { - if (is_exactly_a(a)) { - if (is_exactly_a(b) && b.nops() > a.nops()) - goto factored_b; -factored_a: - size_t num = a.nops(); - exvector g; g.reserve(num); - exvector acc_ca; acc_ca.reserve(num); - ex part_b = b; - for (size_t i=0; isetflag(status_flags::dynallocated); - if (cb) - *cb = part_b; - return (new mul(g))->setflag(status_flags::dynallocated); - } else if (is_exactly_a(b)) { - if (is_exactly_a(a) && a.nops() > b.nops()) - goto factored_a; -factored_b: - size_t num = b.nops(); - exvector g; g.reserve(num); - exvector acc_cb; acc_cb.reserve(num); - ex part_a = a; - for (size_t i=0; isetflag(status_flags::dynallocated); - return (new mul(g))->setflag(status_flags::dynallocated); - } + if (is_exactly_a(a) && is_exactly_a(b) + && (b.nops() > a.nops())) + return gcd_pf_mul(b, a, cb, ca, check_args); + + if (is_exactly_a(b) && (!is_exactly_a(a))) + return gcd_pf_mul(b, a, cb, ca, check_args); + + GINAC_ASSERT(is_exactly_a(a)); + size_t num = a.nops(); + exvector g; g.reserve(num); + exvector acc_ca; acc_ca.reserve(num); + ex part_b = b; + for (size_t i=0; isetflag(status_flags::dynallocated); + if (cb) + *cb = part_b; + return (new mul(g))->setflag(status_flags::dynallocated); } /** Compute LCM (Least Common Multiple) of multivariate polynomials in Z[X].