pjfanning opened a new pull request, #1320: URL: https://github.com/apache/poi/pull/1320
`SUBTOTAL` skips nested `SUBTOTAL`s in its range, so for every formula cell in the range `SheetRefEvaluator.isSubTotal` asked the workbook for the cell's tokens and scanned them for a `SUBTOTAL` `FuncVarPtg` — on **every** evaluation of the enclosing `SUBTOTAL`. For XSSF that is a `FormulaParser.parse` per cell per evaluation (until #1318 lands, after which it is a cache lookup), for HSSF a token decode from the record bytes. ## What changed - `FormulaCellCacheEntry` gets a tri-state `isSubTotal()` (`Boolean`, `null` = not determined). - `WorkbookEvaluator.isSubTotal(EvaluationCell)` (package-private) works the answer out on first use from the tokens and stores it on the cell's entry; `SheetRefEvaluator.isSubTotal` delegates to it after the existing null/formula-type check. - `EvaluationCache.notifyUpdateCell` resets the flag when a formula cell is notified (its formula may have changed); `notifyDeleteCell` already drops the entry and `clearAllCachedResultValues` the whole cache, so those need nothing. The tokens are fetched once per formula cell in the range per evaluator lifetime, and not at all for the many `SUBTOTAL` re-evaluations where the range cells themselves did not change. ## Test `TestSubTotalCellCheckCached` wraps `HSSFEvaluationWorkbook` in a counting `EvaluationWorkbook` and asserts the token fetches per cell: first evaluation — each formula cell in the range twice (evaluate + check), the `SUBTOTAL` once; re-evaluating the notified `SUBTOTAL` — only the `SUBTOTAL` itself; a served result — nothing; after notifying range cells (a nested `SUBTOTAL` becomes a plain formula and vice versa) — they are looked at again and the result follows; after `clearAllCachedResultValues` — everything once more. Fails on trunk at the first "not fetched again" assertion. Locally green: `ss.formula.*` (both modules), `TestHSSFFormulaEvaluator*`, `TestXSSFFormulaEvaluator*` (incl. the hidden-rows suites, which are all about `SUBTOTAL`), `TestFormulaEvaluatorOnXSSF`, `ss.usermodel.*`. `changes.xml` left for you. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
