ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/ray/src/common/calexpr.c
(Generate patch)

Comparing ray/src/common/calexpr.c (file contents):
Revision 2.54 by greg, Sat Dec 6 02:58:05 2025 UTC vs.
Revision 2.55 by greg, Sat Dec 6 04:07:05 2025 UTC

# Line 235 | Line 235 | epflatten(                     /* flatten hierarchies for '+', '*' */
235              *ep = *ep1;
236              efree(ep1);         /* not epfree()! */
237          }
238 <    if ((epar->nkids <= 2) | !(esupport & E_RCONST))
238 >    if (!(esupport & E_RCONST))
239          return;
240      ep1 = NULL;                 /* combine constants in sum/product */
241      for (ep = epar->v.kid; ep != NULL; ep = ep->sibling)
# Line 246 | Line 246 | epflatten(                     /* flatten hierarchies for '+', '*' */
246          }
247      if (ep1 == NULL)
248          return;
249 <    ep1->v.num = combined;      /* drop following constants */
249 >    ep1->v.num = combined;      /* assumes commutative property, also */
250      while (ep1->sibling != NULL)
251          if (ep1->sibling->type == NUM) {
252              ep = ep1->sibling;
253              ep1->sibling = ep->sibling;
254 <            efree(ep);
254 >            epar->nkids--;
255 >            efree(ep);          /* drop subsumed constant */
256          } else
257              ep1 = ep1->sibling;
258 +
259 +    if (epar->nkids == 1) {     /* late constant expression? */
260 +        ep = epar->v.kid;
261 +        *epar = *ep;
262 +        efree(ep);
263 +    }
264   }
265  
266  

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)