github.com/minio/simdjson-go@v0.4.6-0.20231116094823-04d21cddf993/options.go (about)

     1  package simdjson
     2  
     3  // ParserOption is a parser option.
     4  type ParserOption func(pj *internalParsedJson) error
     5  
     6  // WithCopyStrings will copy strings so they no longer reference the input.
     7  // For enhanced performance, simdjson-go can point back into the original JSON buffer for strings,
     8  // however this can lead to issues in streaming use cases scenarios, or scenarios in which
     9  // the underlying JSON buffer is reused. So the default behaviour is to create copies of all
    10  // strings (not just those transformed anyway for unicode escape characters) into the separate
    11  // Strings buffer (at the expense of using more memory and less performance).
    12  // Default: true - strings are copied.
    13  func WithCopyStrings(b bool) ParserOption {
    14  	return func(pj *internalParsedJson) error {
    15  		pj.copyStrings = b
    16  		return nil
    17  	}
    18  }