Skip to content

fix(core): bound date-time detection scans (#1004) - #1170

Closed
LabDennis wants to merge 1 commit into
storytold:mainfrom
LabDennis:fix/linear-datetime-detection
Closed

LabDennis wants to merge 1 commit into
storytold:mainfrom
LabDennis:fix/linear-datetime-detection

Conversation

@LabDennis

@LabDennis LabDennis commented Oct 13, 2026 •

Copy link
Copy Markdown

Long ordinary text containing many spaces made date-time detection retry both parsers at every space. CSV imports and cell entry could therefore spend quadratic time deciding that a field was just text.

Closes #1004.

Only the final two token boundaries can begin a supported time (one token, optionally followed by AM/PM). The parser now checks those candidates, preserves the existing ASCII-space delimiter rule, limits date/time component collection to the supported arity, and borrows the lowercased time body instead of copying it again. Unrecognised input retains its original text.

Validation on Windows / Rust 1.95, based on upstream 84acf62:

  • All 196 tests across core and XLSX pass, including a CSV regression with a long text field and both workbook date systems.
  • A deterministic regression caps candidate count, and 480 combinations cover supported date/time forms and mixed whitespace. The candidate-count regression fails against the original scan.
  • Strict core Clippy, formatting, assets, layers and the full WASM gate pass (11 crates; one existing UI dead-code warning).
  • Full xtask ci stops at the unchanged collapsible_match finding in crates/xlsx/src/xls/mod.rs:273. Separate parity and keytip checks also report stale generated files, neither changed by this PR. No full-green workspace CI claim.

Bounded microbenchmark, five parses of a synthetic space-rich text field, same machine/profile:

Words Before After
1,000 39.46 ms 0.131 ms
2,000 145.75 ms 0.225 ms
4,000 556.19 ms 0.415 ms

This measures input parsing only, not whole-application or complete CSV-import performance. Reproduce with cargo test -p gridcraft-core space_rich_input_timing -- --ignored --nocapture; ordinary tests have no timing thresholds.

Upstream main, issue status and open PRs were rechecked before publication. Related #1132 changes day-first date recognition, #1114 passes workbook date systems to formula arguments, and #1168 adds a conversion preference; this PR keeps the existing grammar and conversion policy.

The branch is now based on upstream d9d09f0baa91. History: 1 → 1 commits. The rewritten file tree was checked against the previous PR plus current upstream, preserving prior integration resolutions.

Scoped Windows regression checks: 18 passed, 1 ignored, zero failures. Formatting, locked Cargo metadata, asset and layer checks passed. This is scoped validation, not a new full-workspace or cross-platform CI claim.

@LabDennis
LabDennis force-pushed the fix/linear-datetime-detection branch from fa198e1 to f91ed73 Compare October 16, 2026 07:42
@LabDennis

Copy link
Copy Markdown
Author

Rebased onto current main (f1894c6) as f91ed73; retained the new upstream file-format documentation while keeping the bounded date-time detection fix. Parser and CSV regression tests, WASM, formatting, assets and layers pass. Scoped Clippy still reports two lints in unchanged upstream files (crates/xlsx/src/xls/mod.rs:273 and crates/xlsx/src/tests/passthrough_tests.rs:480); these files are identical to the current target branch and were not changed or suppressed.

jesusthehelper-oss added a commit to jesusthehelper-oss/gridcraft that referenced this pull request Oct 19, 2026
@LabDennis LabDennis closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(core): date-time detection rescans space-rich text quadratically

1 participant