singleexit

package
v0.0.0-...-b91b1e7 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2019 License: BSD-2-Clause Imports: 1 Imported by: 0

README

Single exit

In a helper, you might consider to have a single exit point for clarity purpose. This structure produces overly complex code easily replaced by range. In Go 1.11, the code is on average 5% faster except towards the end of the searched range. With Go 1.12, codes are equivalent as range is regularly catching up the while structure.

src>go test -bench=. ./singleexit

go version go1.11.1 windows/amd64 while vs range

go version go1.12 windows/amd64

In the box, before the not found case, you can see the cost of exiting a for loop just before its end.

while vs range

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindString

func FindString(s string) (b bool)

One exit point and a default value

func FindStringRange

func FindStringRange(s string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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