unsplit

package
v0.0.0-...-19f838f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2018 License: MIT Imports: 1 Imported by: 1

README

unsplit is for when the cost of creating a [][]byte from bytes.Split is a problem. it successively returns a slice of each token in the string without creating a new [][]byte.

It can be 3 times faster than bytes.Split() and 2 times fater than bytes.SplitN (though both of those functions are faster in go1.9+ so the improvement is less.

BenchmarkUnsplit-4   	10000000	       165 ns/op
BenchmarkSplit-4     	 3000000	       487 ns/op
BenchmarkSplitN-4    	 5000000	       292 ns/op

Documentation

Overview

Packge unsplit is a faster alternative to bytes.Split when a [][]byte is not needed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Split

type Split struct {
	// contains filtered or unexported fields
}

Split has the Next method.

func New

func New(line []byte, sep []byte) *Split

New returns an iterable of each item in the line.

func (*Split) Next

func (u *Split) Next() []byte

Next returns the next item in the line or nil when done.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL