changeset 21:527acdd2d097

Make parser 5x faster
author Lewin Bormann <lbo@spheniscida.de>
date Thu, 15 Dec 2022 20:53:54 +0100
parents 6160397412c3
children 1ed3228c05ed
files 13/13.jl
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/13/13.jl	Thu Dec 15 20:49:53 2022 +0100
+++ b/13/13.jl	Thu Dec 15 20:53:54 2022 +0100
@@ -2,7 +2,7 @@
 
 List = Delayed()
 IntOrList() = PInt64() | List
-ListElement() = (IntOrList() + E",") | IntOrList()
+ListElement() = (IntOrList() + Repeat(E",", 0, 1))
 List.matcher = (E"[" + Repeat(ListElement()) + E"]") |> identity
 
 const Element = Union{Int,Vector};
@@ -40,7 +40,7 @@
 end
 
 function parse_list(s::String)::Element
-    r = parse_one(s, IOL; flatten=false);
+    r = parse_one(s, IOL);
     any_to_elem(r[1])
 end
 
@@ -63,6 +63,7 @@
 end
 
 println("PART 1 TEST");
-run_file("13/test_input.txt");
+@time run_file("13/test_input.txt");
 println("PART 1 INPUT");
-run_file("13/input.txt");
+@time run_file("13/input.txt");
+@time run_file("13/input.txt");