Documentation ¶
Index ¶
- func InternBytes(b []byte) string
- func InternString(s string) string
- func Itoa(n int) string
- func LimitStringLen(s string, maxLen int) string
- func ResizeNoCopyMayOverallocate(b []byte, n int) []byte
- func ResizeNoCopyNoOverallocate(b []byte, n int) []byte
- func ResizeWithCopyMayOverallocate(b []byte, n int) []byte
- func ResizeWithCopyNoOverallocate(b []byte, n int) []byte
- func ToUnsafeBytes(s string) (b []byte)
- func ToUnsafeString(b []byte) string
- type ByteBuffer
- func (bb *ByteBuffer) MustClose()
- func (bb *ByteBuffer) MustReadAt(p []byte, offset int64)
- func (bb *ByteBuffer) NewReader() filestream.ReadCloser
- func (bb *ByteBuffer) Path() string
- func (bb *ByteBuffer) ReadFrom(r io.Reader) (int64, error)
- func (bb *ByteBuffer) Reset()
- func (bb *ByteBuffer) Write(p []byte) (int, error)
- type ByteBufferPool
- type FastStringMatcher
- type FastStringTransformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InternBytes ¶ added in v1.86.0
InternBytes interns b as a string
func InternString ¶ added in v1.82.0
InternString returns interned s.
This may be needed for reducing the amounts of allocated memory.
func Itoa ¶ added in v1.85.0
Itoa returns string representation of n.
This function doesn't allocate memory on repeated calls for the same n.
func LimitStringLen ¶ added in v1.79.0
LimitStringLen limits the length of s to maxLen.
If len(s) > maxLen, then the function concatenates s prefix with s suffix.
func ResizeNoCopyMayOverallocate ¶ added in v1.73.0
ResizeNoCopyMayOverallocate resizes b to minimum n bytes and returns the resized buffer (which may be newly allocated).
If newly allocated buffer is returned then b contents isn't copied to it.
func ResizeNoCopyNoOverallocate ¶ added in v1.73.0
ResizeNoCopyNoOverallocate resizes b to exactly n bytes and returns the resized buffer (which may be newly allocated).
If newly allocated buffer is returned then b contents isn't copied to it.
func ResizeWithCopyMayOverallocate ¶ added in v1.73.0
ResizeWithCopyMayOverallocate resizes b to minimum n bytes and returns the resized buffer (which may be newly allocated).
If newly allocated buffer is returned then b contents is copied to it.
func ResizeWithCopyNoOverallocate ¶ added in v1.73.0
ResizeWithCopyNoOverallocate resizes b to exactly n bytes and returns the resized buffer (which may be newly allocated).
If newly allocated buffer is returned then b contents is copied to it.
func ToUnsafeBytes ¶
ToUnsafeBytes converts s to a byte slice without memory allocations.
The returned byte slice is valid only until s is reachable and unmodified.
func ToUnsafeString ¶
ToUnsafeString converts b to string without memory allocations.
The returned string is valid only until b is reachable and unmodified.
Types ¶
type ByteBuffer ¶
type ByteBuffer struct { // B is the underlying byte slice. B []byte }
ByteBuffer implements a simple byte buffer.
func (*ByteBuffer) MustClose ¶
func (bb *ByteBuffer) MustClose()
MustClose closes bb for subsequent re-use.
func (*ByteBuffer) MustReadAt ¶ added in v1.33.0
func (bb *ByteBuffer) MustReadAt(p []byte, offset int64)
MustReadAt reads len(p) bytes starting from the given offset.
func (*ByteBuffer) NewReader ¶
func (bb *ByteBuffer) NewReader() filestream.ReadCloser
NewReader returns new reader for the given bb.
func (*ByteBuffer) Path ¶ added in v1.91.0
func (bb *ByteBuffer) Path() string
Path returns an unique id for bb.
type ByteBufferPool ¶
type ByteBufferPool struct {
// contains filtered or unexported fields
}
ByteBufferPool is a pool of ByteBuffers.
func (*ByteBufferPool) Get ¶
func (bbp *ByteBufferPool) Get() *ByteBuffer
Get obtains a ByteBuffer from bbp.
type FastStringMatcher ¶ added in v1.82.0
type FastStringMatcher struct {
// contains filtered or unexported fields
}
FastStringMatcher implements fast matcher for strings.
It caches string match results and returns them back on the next calls without calling the matchFunc, which may be expensive.
func NewFastStringMatcher ¶ added in v1.82.0
func NewFastStringMatcher(matchFunc func(s string) bool) *FastStringMatcher
NewFastStringMatcher creates new matcher, which applies matchFunc to strings passed to Match()
matchFunc must return the same result for the same input.
func (*FastStringMatcher) Match ¶ added in v1.82.0
func (fsm *FastStringMatcher) Match(s string) bool
Match applies matchFunc to s and returns the result.
type FastStringTransformer ¶ added in v1.82.0
type FastStringTransformer struct {
// contains filtered or unexported fields
}
FastStringTransformer implements fast transformer for strings.
It caches transformed strings and returns them back on the next calls without calling the transformFunc, which may be expensive.
func NewFastStringTransformer ¶ added in v1.82.0
func NewFastStringTransformer(transformFunc func(s string) string) *FastStringTransformer
NewFastStringTransformer creates new transformer, which applies transformFunc to strings passed to Transform()
transformFunc must return the same result for the same input.
func (*FastStringTransformer) Transform ¶ added in v1.82.0
func (fst *FastStringTransformer) Transform(s string) string
Transform applies transformFunc to s and returns the result.