Commit Graph

588 Commits

Author SHA1 Message Date
Cameron Moore a7b50eb8f1 Tidy (#511)
* Disconnect package godoc comment from imported file

* Add missing newline in toml.abnf

* Tag testing helper funcs
2021-04-15 16:49:19 -04:00
Cameron Moore 24b62ebe61 Simplify scanFollows usage (#510)
Use static functions to avoid declaring global vars and creating more
package init costs.  This change has no negative effects on benchmarks
in my testing.
2021-04-15 16:48:19 -04:00
Thomas Pelletier 9bc4641a49 ci-lint: disable ifshort 2021-04-15 13:37:24 -04:00
Thomas Pelletier b86b890b8d decoder: handle private anonymous structs
Ref #508
2021-04-15 12:49:24 -04:00
Vincent Serpoul 080baa8574 golangci-lint: localtime (#509) 2021-04-15 12:44:31 -04:00
Thomas Pelletier 0537b928df decoder: add test for #507 2021-04-15 11:36:36 -04:00
Thomas Pelletier 2eff2d082a Rename branch v2-wip -> v2 v2.0.0-alpha.1 2021-04-15 11:26:14 -04:00
Vincent Serpoul 59cddbc573 Golangci-lint v2 part two (#498) 2021-04-15 10:29:46 -04:00
Thomas Pelletier 9e122af5fc encoder: support multiline strings + local options 2021-04-10 17:58:37 -04:00
Cameron Moore ed1f9ed9de Add sanity check tests to benchmark dataset (#497)
Marshal results into JSON and ensure all runners match
2021-04-09 11:27:22 -04:00
Cameron Moore 466bfe8664 encoder: inline tables create map in nil interface (#496)
Co-authored-by: Thomas Pelletier <pelletier.thomas@gmail.com>
2021-04-09 09:02:00 -04:00
Thomas Pelletier e1f035461b encoder: simplify quoted strings escaping 2021-04-08 22:02:41 -04:00
Thomas Pelletier 84f9e9bceb ci: run benchmark tests 2021-04-08 19:43:14 -04:00
Thomas Pelletier ca41df4a59 encoder: only create empty map when target exists 2021-04-08 19:40:34 -04:00
Thomas Pelletier f2378983d9 encoder: added test for #287 2021-04-08 10:24:38 -04:00
Thomas Pelletier 37714006b6 V2 Marshaler MVP (#495) 2021-04-08 10:07:29 -04:00
Thomas Pelletier 275e366c17 decoder: handle casting local date into time.Time
Refs #494
2021-04-08 08:00:31 -04:00
Vincent Serpoul 18af62d3ea Golangci-lint v2 part one (#492) 2021-04-07 13:39:01 -04:00
jidicula af00765ca0 Address golangci-lint warnings in unmarshal_imported_test.go (#493)
* refactor(tracker): Remove unreachable return

* refactor(unmarshal_imported_test): Mark unused camelCase test

golangci-lint indicates `TestUnmarshalCamelCaseKey` as unused (it's
currently skipped).

* refactor(unmarshal_imported_test): Mark unused type

golangci-lint indicates `customPointerMarshaler` as unused.

* refactor(unmarshal_imported_test): Mark unused type

golangci-lint indicates `textPointerMarshaler` as unused.

* refactor(unmarshal_imported_test): Mark unused type

golangci-lint indicates `precedentMarshaler` and its methods as
unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `testDurationToml2` as unused.

* refactor(unmarshal_imported_test): Mark unused type

golangci-lint indicates `testBadDuration` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `testDurationToml` as unused.

* refactor(unmarshal_imported_test): Mark unused type

golangci-lint indicates `testDuration` as unused.

* refactor(unmarshal_imported_test): Mark unused type

golangci-lint indicates `testDocCustomTag` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `testDocCustomTagData` as unused.

* refactor(unmarshal_imported_test): Mark unused type

golangci-lint indicates `testDocBasicsCustomTag` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `testDocBasicToml` as unused.

* refactor(unmarshal_imported_test): Mark unused type

golangci-lint indicates `structArrayNoTag` as unused.

* refactor(unmarshal_imported_test): Mark unused type

golangci-lint incorrectly indicates `check` as unused.

* refactor(unmarshal_imported_test): Mark unused struct field

golangci-lint indicates `testDoc.err` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `customMultilineTagTestToml` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `customCommentedTagTestToml` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `customCommentTagTestToml` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `customTagTestToml` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `mapsTestToml` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `mapsTestData` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `commentTestToml` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `nestedCustomMarshalerToml` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `nestedCustomMarshalerData` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `customMarshalerToml` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `mapTestDoc` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `quotedKeyMarshalTestToml` as unused.

* refactor(unmarshal_imported_test): Mark unused var

golangci-lint indicates `quotedKeyMarshalTestData` as unused.
2021-04-05 14:30:17 -04:00
Cameron Moore 5f877c52fd Add additional dataset to benchmarks (#490)
Adding several files to stress test the unmarshaller.  Most were
converted from JSON so they may not be very realistic use cases.

```
goos: linux
goarch: amd64
pkg: github.com/pelletier/go-toml/v2/benchmark
cpu: Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz
BenchmarkUnmarshalDataset/config/v2-2                 16          66339063 ns/op          15.81 MB/s    16850159 B/op     645454 allocs/op
BenchmarkUnmarshalDataset/config/v1-2                  7         147289186 ns/op           7.12 MB/s    60669811 B/op     870486 allocs/op
BenchmarkUnmarshalDataset/config/bs-2                 12          88966009 ns/op          11.79 MB/s    29949268 B/op     705573 allocs/op
BenchmarkUnmarshalDataset/canada/v2-2                  8         145433377 ns/op          15.14 MB/s    74282227 B/op     895641 allocs/op
BenchmarkUnmarshalDataset/canada/v1-2                  3         434913677 ns/op           5.06 MB/s    138664290 B/op   1897300 allocs/op
BenchmarkUnmarshalDataset/citm_catalog/v2-2                   19          55256979 ns/op          10.10 MB/s    37122952 B/op     369492 allocs/op
BenchmarkUnmarshalDataset/citm_catalog/v1-2                   10         110343191 ns/op           5.06 MB/s    54743595 B/op     727704 allocs/op
BenchmarkUnmarshalDataset/citm_catalog/bs-2                   21          51634081 ns/op          10.81 MB/s    17196872 B/op     325830 allocs/op
BenchmarkUnmarshalDataset/twitter/v2-2                        50          26660937 ns/op          16.57 MB/s    15580238 B/op     156394 allocs/op
BenchmarkUnmarshalDataset/twitter/v1-2                        30          43128488 ns/op          10.25 MB/s    21203420 B/op     266110 allocs/op
BenchmarkUnmarshalDataset/twitter/bs-2                        48          27337976 ns/op          16.16 MB/s     8795405 B/op     145370 allocs/op
BenchmarkUnmarshalDataset/code/v2-2                            4         276279202 ns/op           9.71 MB/s    59293948 B/op    2907227 allocs/op
BenchmarkUnmarshalDataset/code/v1-2                            3         421910642 ns/op           6.36 MB/s    161733770 B/op   2478194 allocs/op
BenchmarkUnmarshalDataset/code/bs-2                            4         323158157 ns/op           8.31 MB/s    133056988 B/op   1439475 allocs/op
BenchmarkUnmarshalDataset/example/v2-2                      2444            479553 ns/op          16.89 MB/s      237606 B/op       3609 allocs/op
BenchmarkUnmarshalDataset/example/v1-2                      1321            911995 ns/op           8.88 MB/s      377502 B/op       6133 allocs/op
BenchmarkUnmarshalDataset/example/bs-2                      1898            555649 ns/op          14.58 MB/s      178485 B/op       3362 allocs/op
BenchmarkUnmarshalSimple/v2-2                             896760              1200 ns/op
BenchmarkUnmarshalSimple/v1-2                             207364              6070 ns/op
BenchmarkUnmarshalSimple/bs-2                             420952              2925 ns/op
BenchmarkReferenceFile/v2-2                                29473             39433 ns/op         132.93 MB/s       11812 B/op        253 allocs/op
BenchmarkReferenceFile/v1-2                                 2823            361383 ns/op          14.51 MB/s      136470 B/op       2745 allocs/op
BenchmarkReferenceFile/bs-2                                 3097            391116 ns/op          13.40 MB/s       80795 B/op       1729 allocs/op
PASS
ok      github.com/pelletier/go-toml/v2/benchmark       34.255s
```
2021-04-01 10:13:13 -04:00
Thomas Pelletier 92b16cad91 Simplify context implementation and fix new lines bug 2021-03-31 09:57:19 -04:00
Thomas Pelletier 4a4c2c2a5f Update readme 2021-03-31 09:15:33 -04:00
Thomas Pelletier 5d905981cf CI: add dependabot 2021-03-30 22:03:39 -04:00
Thomas Pelletier 7ccacf158e Test for #252 2021-03-30 21:53:01 -04:00
Thomas Pelletier 739ceda96c Move github pull request template 2021-03-30 21:45:43 -04:00
Thomas Pelletier 32da85ab11 Decoding error position tracking 2021-03-30 21:43:57 -04:00
Thomas Pelletier 18d45c446b wip: decoder errors 2021-03-30 19:52:02 -04:00
Thomas Pelletier bcd5333b03 Enable ci on v2-wip branch pull requests 2021-03-30 12:38:26 -04:00
Cameron Moore e5255a5be2 Set bytes in ReferenceFile benchmark to show throughput results (#489) 2021-03-30 12:34:25 -04:00
Thomas Pelletier cf288a51c5 Wip errors reporting 2021-03-30 10:59:35 -04:00
Thomas Pelletier 72a1afdcb2 Add some unsafe helper to track errors 2021-03-29 22:33:28 -04:00
Thomas Pelletier 2714786b37 Add decoder interface 2021-03-29 21:30:41 -04:00
Thomas Pelletier 51d78a5f0c Fix unmarshaling of literal keys
Ref #427.
2021-03-29 20:58:51 -04:00
Thomas Pelletier 78389c641a Test for #475 2021-03-29 20:46:09 -04:00
Thomas Pelletier c3fc668f27 Test for #458 2021-03-29 20:38:48 -04:00
Thomas Pelletier 7f016efe03 Test for #484 2021-03-29 20:28:51 -04:00
Thomas Pelletier 269b742eb2 Enable race condition detector in CI 2021-03-29 20:17:05 -04:00
Cameron Moore 7d8ea80dc3 Fix scanning of float with leading zero (#486) 2021-03-29 20:07:26 -04:00
Cameron Moore 6165b9454f Identify test helper functions (#487) 2021-03-29 20:06:46 -04:00
Thomas Pelletier 2ddbf6be6d Implement duplicate and key types check 2021-03-29 10:45:50 -04:00
Thomas Pelletier da21b0aecf wip: correctness pass on the AST 2021-03-28 22:12:19 -04:00
Thomas Pelletier 829c005784 Fix unicode decoding 2021-03-28 11:03:43 -04:00
Thomas Pelletier b24eb93e8e Fix literal multiline parsing 2021-03-28 00:23:50 -04:00
Thomas Pelletier 7dc5550057 Fix multiline basic string parsing 2021-03-28 00:17:58 -04:00
Thomas Pelletier 9a436c7eeb Remove logging in test 2021-03-28 00:06:40 -04:00
Thomas Pelletier 72c999ecbf Fix trailing commas in arrays 2021-03-28 00:04:25 -04:00
Thomas Pelletier e5a091a092 Don't depend on my computer path 2021-03-27 23:43:24 -04:00
Thomas Pelletier 317b36b24b Add back license 2021-03-26 09:53:21 -04:00
Thomas Pelletier 636a75f316 Import tomltestgen
Handful are failing.
2021-03-26 09:51:35 -04:00
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