Declarative CSV codecs
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Upgrade to ocamlformat 0.29.0; fix csvt/sexpt streaming; reformat

- Update .ocamlformat to 0.29.0 across all 591 files
- csvt: reuse single Buffer.t for field reads (no alloc per field)
- sexpt: Obj members decoded from stream into Dict, typed Variant GADT
- Reformat all source files for 0.29.0

+11 -15
+1 -1
.ocamlformat
··· 1 - version = 0.28.1 1 + version = 0.29.0
+10 -14
lib/csvt.ml
··· 397 397 mutable buf_pos : int; 398 398 mutable buf_len : int; 399 399 mutable eof : bool; 400 + field_buf : Buffer.t; (* reused across all fields *) 400 401 } 401 402 402 403 type field_result = Field of string | End_of_row | Eof ··· 407 408 buf = Bytes.create buf_size; 408 409 buf_pos = 0; 409 410 buf_len = 0; 411 + field_buf = Buffer.create 64; 410 412 eof = false; 411 413 } 412 414 ··· 458 460 (* Read a quoted field: opening quote already consumed. 459 461 Handles "" escapes. Returns field content without quotes. *) 460 462 let read_quoted s = 461 - let acc = Buffer.create 64 in 463 + Buffer.clear s.field_buf; 462 464 let rec loop () = 463 465 match peek s with 464 - | None -> 465 - (* EOF inside quoted field — return what we have *) 466 - Buffer.contents acc 466 + | None -> Buffer.contents s.field_buf 467 467 | Some '"' -> ( 468 468 advance s; 469 - (* Check for escaped quote "" *) 470 469 match peek s with 471 470 | Some '"' -> 472 471 advance s; 473 - Buffer.add_char acc '"'; 472 + Buffer.add_char s.field_buf '"'; 474 473 loop () 475 - | _ -> 476 - (* End of quoted field — skip to next delimiter *) 477 - Buffer.contents acc) 474 + | _ -> Buffer.contents s.field_buf) 478 475 | Some c -> 479 476 advance s; 480 - Buffer.add_char acc c; 477 + Buffer.add_char s.field_buf c; 481 478 loop () 482 479 in 483 480 loop () 484 481 485 - (* Read an unquoted field. Returns field content. *) 486 482 let read_unquoted s = 487 - let acc = Buffer.create 64 in 483 + Buffer.clear s.field_buf; 488 484 let rec loop () = 489 485 match peek s with 490 - | None | Some ',' | Some '\n' | Some '\r' -> Buffer.contents acc 486 + | None | Some ',' | Some '\n' | Some '\r' -> Buffer.contents s.field_buf 491 487 | Some c -> 492 488 advance s; 493 - Buffer.add_char acc c; 489 + Buffer.add_char s.field_buf c; 494 490 loop () 495 491 in 496 492 loop ()