ex power::expand(unsigned options) const
{
- if (is_a<symbol>(basis) && exponent.info(info_flags::integer))
- return (new power(*this))->setflag(status_flags::dynallocated | status_flags::expanded);
-
- if (options == 0 && (flags & status_flags::expanded))
+ if (is_a<symbol>(basis) && exponent.info(info_flags::integer)) {
+ // A special case worth optimizing.
+ setflag(status_flags::expanded);
return *this;
-
+ }
+
const ex expanded_basis = basis.expand(options);
const ex expanded_exponent = exponent.expand(options);