104 Commits

Author SHA1 Message Date
Thomas Pelletier 390927a0cd Reuse AST storage between top-level expressions
```
Comparing:
	old: v2-wip/1da2fc7 (2021-03-25 20:38:05 -0400 -0400)
	run: v2-wip/3f23ab9 (2021-03-25 22:35:06 -0400 -0400)
-----------------------------------------------------------
name                  old time/op    new time/op    delta
UnmarshalSimple/v2-8     700ns ± 3%     705ns ± 2%     ~     (p=0.690 n=5+5)
UnmarshalSimple/v1-8    3.85µs ± 1%    4.02µs ± 4%   +4.19%  (p=0.032 n=5+5)
UnmarshalSimple/bs-8    2.34µs ± 2%    2.38µs ± 3%     ~     (p=0.310 n=5+5)
ReferenceFile/v2-8      32.2µs ±13%    23.9µs ± 1%  -25.79%  (p=0.008 n=5+5)
ReferenceFile/v1-8       270µs ± 2%     264µs ± 2%     ~     (p=0.095 n=5+5)
ReferenceFile/bs-8       291µs ± 0%     294µs ± 0%   +0.88%  (p=0.008 n=5+5)

name                  old alloc/op   new alloc/op   delta
ReferenceFile/v2-8      37.1kB ± 0%     6.7kB ± 0%  -81.91%  (p=0.008 n=5+5)
ReferenceFile/v1-8       131kB ± 0%     131kB ± 0%     ~     (p=0.444 n=5+5)
ReferenceFile/bs-8      80.8kB ± 0%    80.8kB ± 0%     ~     (p=0.571 n=5+5)

name                  old allocs/op  new allocs/op  delta
ReferenceFile/v2-8         152 ± 0%       148 ± 0%   -2.63%  (p=0.008 n=5+5)
ReferenceFile/v1-8       2.65k ± 0%     2.65k ± 0%     ~     (all equal)
ReferenceFile/bs-8       1.73k ± 0%     1.73k ± 0%     ~     (all equal)

~/s/g/p/g/benchmark$ go test -bench=.
goos: linux
goarch: amd64
pkg: github.com/pelletier/go-toml/v2/benchmark
cpu: Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
BenchmarkUnmarshalSimple/v2-8         	 1692444	       710.7 ns/op
BenchmarkUnmarshalSimple/v1-8         	  307609	      3862 ns/op
BenchmarkUnmarshalSimple/bs-8         	  520429	      2285 ns/op
BenchmarkReferenceFile/v2-8           	   50395	     24006 ns/op	    6704 B/op	     148 allocs/op
BenchmarkReferenceFile/v1-8           	    4144	    264655 ns/op	  130567 B/op	    2649 allocs/op
BenchmarkReferenceFile/bs-8           	    3969	    293635 ns/op	   80784 B/op	    1729 allocs/op
PASS
ok  	github.com/pelletier/go-toml/v2/benchmark	8.143s
```
2021-03-25 22:37:16 -04:00
Thomas Pelletier 1d332cd112 Add documentation for the AST 2021-03-25 20:46:31 -04:00
Thomas Pelletier 9d3a912da0 Remove unused interface
Comparing:
	old: v2-wip/17299c9 (2021-03-25 20:19:40 -0400 -0400)
	run: v2-wip/1da2fc7 (2021-03-25 20:38:05 -0400 -0400)
-----------------------------------------------------------
name                  old time/op    new time/op    delta
UnmarshalSimple/v2-8     755ns ± 3%     700ns ± 3%   -7.26%  (p=0.008 n=5+5)
UnmarshalSimple/v1-8    3.87µs ± 0%    3.85µs ± 1%     ~     (p=0.254 n=4+5)
UnmarshalSimple/bs-8    2.44µs ± 4%    2.34µs ± 2%     ~     (p=0.056 n=5+5)
ReferenceFile/v2-8      33.5µs ± 7%    32.2µs ±13%     ~     (p=0.421 n=5+5)
ReferenceFile/v1-8       269µs ± 3%     270µs ± 2%     ~     (p=1.000 n=5+5)
ReferenceFile/bs-8       296µs ± 2%     291µs ± 0%     ~     (p=0.095 n=5+5)

name                  old alloc/op   new alloc/op   delta
ReferenceFile/v2-8      38.9kB ± 0%    37.1kB ± 0%   -4.77%  (p=0.008 n=5+5)
ReferenceFile/v1-8       131kB ± 0%     131kB ± 0%     ~     (all equal)
ReferenceFile/bs-8      80.8kB ± 0%    80.8kB ± 0%     ~     (p=0.841 n=5+5)

name                  old allocs/op  new allocs/op  delta
ReferenceFile/v2-8         181 ± 0%       152 ± 0%  -16.02%  (p=0.008 n=5+5)
ReferenceFile/v1-8       2.65k ± 0%     2.65k ± 0%     ~     (all equal)
ReferenceFile/bs-8       1.73k ± 0%     1.73k ± 0%     ~     (all equal)
2021-03-25 20:38:45 -04:00
Thomas Pelletier 1bae751a45 Linear array storage for AST 2021-03-25 19:56:02 -04:00
Thomas Pelletier ad538d97c9 Delete reflectbuild 2021-03-24 21:06:38 -04:00
Thomas Pelletier dd5837651d Support TextUnmarshaler 2021-03-24 21:02:02 -04:00
Thomas Pelletier a0d031abec Arrays support 2021-03-24 20:21:55 -04:00
Thomas Pelletier a25f636a07 Add array support todo 2021-03-23 21:18:19 -04:00
Thomas Pelletier bfeb32c9ce Make unmarshal to interface{} consistent with encoding/json 2021-03-23 20:03:45 -04:00
Thomas Pelletier c6f117c45d Handle pointers in slices 2021-03-23 09:15:48 -04:00
Thomas Pelletier e78ccff9a4 Fix parsing integer 0 2021-03-23 09:02:48 -04:00
Thomas Pelletier fcc91f2618 Progress on date/times 2021-03-22 09:59:15 -04:00
Thomas Pelletier 8b34e54764 Improve DOT representation for AST 2021-03-18 22:10:31 -04:00
Thomas Pelletier 9ec4e86883 Handle struct field name variations 2021-03-18 20:42:41 -04:00
Thomas Pelletier 93a7b0d77d Skip AST branches that don't exist in the target 2021-03-18 20:30:51 -04:00
Thomas Pelletier 3e8b8db786 Unmarshal into pointers 2021-03-18 20:02:32 -04:00
Thomas Pelletier 8957a768ef Next stop: pointers 2021-03-18 19:52:11 -04:00
Thomas Pelletier f9f9ccb777 Basic array table implementation 2021-03-16 10:24:19 -04:00
Thomas Pelletier 00b2f776a9 Replace branch with AST version 2021-03-15 08:46:35 -04:00
Thomas Pelletier b8df31de84 Comment out date/time tests for now 2021-03-14 18:13:57 -04:00
Thomas Pelletier 590d674153 Unmarshal ints and floats 2021-03-14 18:06:34 -04:00
Thomas Pelletier 9a1cfcdd8e Replace parser's int or float code with scanner 2021-03-14 17:22:53 -04:00
Thomas Pelletier 590d7faf65 Parser emits AST node for all kinds of strings 2021-03-14 16:16:29 -04:00
Thomas Pelletier de035f0fed Standard tables in parser 2021-03-14 16:11:23 -04:00
Thomas Pelletier 04925e4882 Handle bools 2021-03-14 15:52:22 -04:00
Thomas Pelletier 3760527218 Unmarshal tests 2021-03-13 23:42:38 -05:00
Thomas Pelletier fa7ee6461a Inline tables 2021-03-13 23:06:16 -05:00
Thomas Pelletier fbf01f7683 Handle Table 2021-03-13 22:48:31 -05:00
Thomas Pelletier a0548e793c Unmarshal slices of strings 2021-03-13 22:07:36 -05:00
Thomas Pelletier d8be04d4a8 Handle simple string slice 2021-03-13 18:45:03 -05:00
Thomas Pelletier 21d3e85fcc Playing with an AST
Idea would be to build a light AST as a first pass, then have the
unmarshaler and Document parser do what they need with it.
2021-03-13 11:38:09 -05:00
Thomas Pelletier 93a74fca35 todo: inline tables 2021-03-08 21:59:43 -05:00
Thomas Pelletier a1c9b661b4 Allocate slice if needed 2021-03-08 21:41:03 -05:00
Thomas Pelletier 87b9d1cf98 Handle overflows 2021-03-08 21:01:53 -05:00
Thomas Pelletier 90f3b658c6 Support type aliases 2021-03-08 20:27:04 -05:00
Thomas Pelletier c35bcc5519 Convert returns pointer if a pointer is passed 2021-03-08 10:01:56 -05:00
Thomas Pelletier f698c102c7 Convert should only handle specific types 2021-03-08 09:42:19 -05:00
Thomas Pelletier 2cee819ce4 Going back and forth on whether types should always be converted 2021-03-02 10:37:17 -05:00
Thomas Pelletier bf051f1718 Fixed some tests 2021-03-01 20:50:18 -05:00
Thomas Pelletier c77f1d815c Skip default tags tests 2021-02-19 19:48:43 -05:00
Thomas Pelletier d24deebee3 wip making reflection tests pass 2021-02-19 19:26:46 -05:00
Thomas Pelletier 4526154571 wip 2021-02-19 09:39:50 -05:00
Thomas Pelletier 978143ce99 Ensure that slices have been allocated when entering array 2021-02-19 08:53:19 -05:00
Thomas Pelletier 7f9822db35 Target set methods now check for types 2021-02-19 08:39:18 -05:00
Thomas Pelletier 052233e858 wip: debugging maps 2021-02-18 23:30:46 -05:00
Thomas Pelletier 629a2475a9 Handle maps 2021-02-18 22:39:33 -05:00
Thomas Pelletier 46573551f1 WIP constructing pointers 2021-02-18 21:24:26 -05:00
Thomas Pelletier 9ac08febd2 DateTime/LocalDate/LocalTime implementation 2021-02-10 20:58:22 -05:00
Thomas Pelletier 2341b4df00 Comment out json-based comparison 2021-02-10 18:42:43 -05:00
Thomas Pelletier 6e79ce63c2 Reflect write to embeded structs 2021-02-10 18:34:54 -05:00