MCPcopy Index your code
hub / github.com/pingcap/tidb / MemoizeStr

Function MemoizeStr

pkg/util/stringutil/string_util.go:367–376  ·  view source on GitHub ↗

MemoizeStr returns memoized version of stringFunc. When the result of l is not "", it will be cached and returned directly next time. MemoizeStr is not concurrency safe.

(l func() string)

Source from the content-addressed store, hash-verified

365//
366// MemoizeStr is not concurrency safe.
367func MemoizeStr(l func() string) fmt.Stringer {
368 var result string
369 return StringerFunc(func() string {
370 if result != "" {
371 return result
372 }
373 result = l()
374 return result
375 })
376}
377
378// StringerStr defines a alias to normal string.
379// implement fmt.Stringer

Callers 10

ExplainIDMethod · 0.92
ExplainIDMethod · 0.92
ExplainIDMethod · 0.92
ExplainIDMethod · 0.92
ExplainIDMethod · 0.92
ExplainIDMethod · 0.92
ExplainIDMethod · 0.92
NextMethod · 0.92
ExplainIDMethod · 0.92
TestMemoizeStrFunction · 0.85

Calls 1

StringerFuncFuncType · 0.85

Tested by 1

TestMemoizeStrFunction · 0.68