Skip to content
Snippets Groups Projects
  • Martin Möhrmann's avatar
    f2163c4d
    bytes, strings: align requirements for functions passed to FieldFuncs · f2163c4d
    Martin Möhrmann authored
    golang.org/cl/229763 removed the documentation of requirements of
    the function passed to FieldsFunc. The current implementation does
    not require functions to return consistent results but this had not
    been the case for previous implementations.
    
    Add the requirement for consistent results back to the documentation
    to allow for future implementations to be more allocation efficient
    for an output with more than 32 fields. This is possible with a two
    pass algorithm first determining the number of fields used to allocate
    the output slice and then splitting the input into fields.
    
    While at it align the documentation of bytes.FieldsFunc with
    strings.FieldFunc.
    
    Fixes #38630
    
    Change-Id: Iabbf9ca3dff0daa41f4ec930a21a3dd98e19f122
    Reviewed-on: https://go-review.googlesource.com/c/go/+/230797
    
    
    Run-TryBot: Martin Möhrmann <moehrmann@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
    f2163c4d
    History
    bytes, strings: align requirements for functions passed to FieldFuncs
    Martin Möhrmann authored
    golang.org/cl/229763 removed the documentation of requirements of
    the function passed to FieldsFunc. The current implementation does
    not require functions to return consistent results but this had not
    been the case for previous implementations.
    
    Add the requirement for consistent results back to the documentation
    to allow for future implementations to be more allocation efficient
    for an output with more than 32 fields. This is possible with a two
    pass algorithm first determining the number of fields used to allocate
    the output slice and then splitting the input into fields.
    
    While at it align the documentation of bytes.FieldsFunc with
    strings.FieldFunc.
    
    Fixes #38630
    
    Change-Id: Iabbf9ca3dff0daa41f4ec930a21a3dd98e19f122
    Reviewed-on: https://go-review.googlesource.com/c/go/+/230797
    
    
    Run-TryBot: Martin Möhrmann <moehrmann@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
Code owners
Assign users and groups as approvers for specific file changes. Learn more.