From 98a256e57f2df1b10b7cd75808bee68d8abd1dcd Mon Sep 17 00:00:00 2001 From: Shulhan Date: Wed, 5 Apr 2023 23:04:04 +0700 Subject: lib/strings: merge lib/parser here The first idea of parser is to provide generic parser for both bytes and string. After we introduce lib/parser there is not much changes to that package. Also, since we create another Parser in lib/bytes that accept and return token as []byte, the lib/parser is not unique anymore. The following function/methods changes to minimize conflict in the future, * Lines become LinesOfFile * New become NewParser * Open become OpenForParser * Token become Read * TokenEscaped become ReadEscaped * TokenTrimSpace become ReadNoSpace --- lib/strings/parser_benchmark_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lib/strings/parser_benchmark_test.go (limited to 'lib/strings/parser_benchmark_test.go') diff --git a/lib/strings/parser_benchmark_test.go b/lib/strings/parser_benchmark_test.go new file mode 100644 index 00000000..a41c2128 --- /dev/null +++ b/lib/strings/parser_benchmark_test.go @@ -0,0 +1,22 @@ +// Copyright 2019, Shulhan . All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package strings + +import "testing" + +// Output: +// +// BenchmarkParser_Read-4 59117898 20.2 ns/op 0 B/op 0 allocs/op +func BenchmarkParser_Read(b *testing.B) { + content := `abc;def` + delims := ` /;` + + p := NewParser(content, delims) + + for x := 0; x < b.N; x++ { + p.Read() + p.Load(content, delims) + } +} -- cgit v1.3-6-g1900