refactor: ponytail cleanup - remove waste and simplify#178
Merged
Conversation
- Delete 39 formal loop invariant comment blocks (98 lines) across 8 files These academic-style comments added noise without value for straightforward loops - Extract loadInput() helper in main.zig (-38 lines) Eliminated duplicated format dispatch logic between file and stdin loading Two 42-line switch blocks replaced with single 22-line helper + concise call sites - Simplify inferTypes() in loader.zig (-27 lines) Replaced 11 parallel boolean/enum arrays with single ColumnInference struct Reduced from 11 allocations to 1, eliminated initialization loop Total: -154 lines, zero logic changes, all structural simplifications. All 78 unit tests + 20 integration tests (225 steps) pass.
- Add execSql, columnText, columnName helpers to sqlite.zig (13 call sites) - Add readAllInput, checkMaxRows helpers to sqlite.zig (11 call sites) - Add fatalNoRows helper to xml.zig (3 call sites) - Add firstJsonObject helper to json.zig (3 call sites) - Delete unused LoadOpts struct from format.zig Net reduction: -66 lines (pass 2), -229 lines (combined pass 1+2) All tests pass: 78 unit + 20 integration (225 steps)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ponytail refactor (full intensity) of the sql-pipe codebase. Deleted waste, simplified structures, shortest diff.
Changes
Phase 1: Delete loop invariant comments (-98 lines)
Removed 39 formal loop invariant/bounding function comment blocks across 8 files. These academic-style
// Loop invariant I:/// Bounding function:comments added noise without value — no formal verification tooling consumes them.Files: args.zig, csv.zig, format.zig, json.zig, loader.zig, main.zig, modes/sample.zig, xml.zig
Phase 2: Extract
loadInput()helper (-38 lines)Eliminated duplicated format dispatch logic in
main.zig. Two nearly identical 42-line switch blocks (file loading + stdin loading) replaced with a single 22-lineloadInput()helper + concise call sites.Adding a new input format now requires one change instead of two.
Phase 3: Simplify
inferTypes()(-27 lines)Replaced 11 parallel boolean/enum arrays with a single
ColumnInferencestruct inloader.zig:Impact
Validation
All tests pass:
zig build unit-test -Dbundle-sqlite=true— 78/78zig build test -Dbundle-sqlite=true— 225/225 steps