1. 13 Aug, 2017 3 commits
    • Martin Möhrmann's avatar
      strings: speed up FieldsFunc · fee7f2ab
      Martin Möhrmann authored
      Increases performance of FieldsFunc by recording the start and end
      of the fields in an array. The first 32 fields are saved in a pre-allocated
      array on the stack. This avoids the old behavior of iterating over the
      input string two times but uses more allocations when more than 32 fields
      are encountered.
      
      Additionally code for handling non-ASCII containing strings from Fields is
      removed and replaced by a call to the new faster FieldsFunc function.
      
      Overall this still leads to a slowdown for Fields on non-ASCII strings
      while speeding up Fields in general.
      
      name                      old time/op    new time/op     delta
      Fields/ASCII/16              116ns ± 5%      115ns ± 5%       ~     (p=0.480 n=10+10)
      Fields/ASCII/256             765ns ± 1%      761ns ± 2%       ~     (p=0.171 n=10+10)
      Fields/ASCII/4096           12.5µs ± 1%     12.7µs ± 1%     +1.82%  (p=0.000 n=10+10)
      Fields/ASCII/65536           226µs ± 1%      226µs ± 2%       ~     (p=0.739 n=10+10)
      Fields/ASCII/1048576        5.12ms ± 1%     5.12ms ± 1%       ~     (p=0.696 n=8+10)
      Fields/Mixed/16              172ns ± 1%      233ns ± 1%    +35.90%  (p=0.000 n=9+10)
      Fields/Mixed/256            1.18µs ± 2%     2.45µs ± 1%   +107.47%  (p=0.000 n=10+10)
      Fields/Mixed/4096           20.3µs ± 1%     43.1µs ± 2%   +112.41%  (p=0.000 n=10+10)
      Fields/Mixed/65536           364µs ± 1%      704µs ± 1%    +93.56%  (p=0.000 n=9+10)
      Fields/Mixed/1048576        7.07ms ± 2%    13.34ms ± 4%    +88.83%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/16          274ns ± 1%      188ns ± 3%    -31.44%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/256        3.69µs ± 1%     2.06µs ± 2%    -44.26%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/4096       59.9µs ± 1%     35.3µs ± 2%    -41.10%  (p=0.000 n=10+10)
      FieldsFunc/ASCII/65536       958µs ± 1%      567µs ± 1%    -40.82%  (p=0.000 n=10+9)
      FieldsFunc/ASCII/1048576    16.3ms ± 2%     11.0ms ± 3%    -32.52%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/16          309ns ± 1%      213ns ± 0%    -30.98%  (p=0.000 n=10+6)
      FieldsFunc/Mixed/256        3.83µs ± 1%     2.14µs ± 1%    -44.01%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/4096       66.2µs ± 2%     37.8µs ± 1%    -42.85%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/65536      1.09ms ± 1%     0.63ms ± 1%    -42.73%  (p=0.000 n=10+10)
      FieldsFunc/Mixed/1048576    18.6ms ± 3%     12.0ms ± 2%    -35.50%  (p=0.000 n=10+10)
      
      Fixes #17856
      Fixes #19789
      
      Change-Id: I9f5a560e534566fd81963651f342c8f44cfb0469
      Reviewed-on: https://go-review.googlesource.com/42810Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
      fee7f2ab
    • Martin Möhrmann's avatar
      strconv: fix ParseUint return value on range overflow · fc6b74ce
      Martin Möhrmann authored
      If the value corresponding to the input string cannot be
      represented by an unsigned integer of the given size,
      err.Err = ErrRange and the returned value is the maximum
      magnitude unsigned integer of the appropriate bitSize.
      This is consistent with ParseInt's behavior and the documentation.
      
      Expand tests to test 32 bit test value tables with bitsize 32 set.
      These tests fail without the fix in this CL.
      
      Fixes #21278
      
      Change-Id: I8aab39279ec3e31905fcbf582a916cbf6d9b95da
      Reviewed-on: https://go-review.googlesource.com/55134
      Run-TryBot: Martin Möhrmann <moehrmann@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarJoe Tsai <thebrokentoaster@gmail.com>
      fc6b74ce
    • Joe Tsai's avatar
      archive/tar: simplify toASCII and parseString · 1d812515
      Joe Tsai authored
      Use a simple []byte instead of bytes.Buffer to create a string.
      Use bytes.IndexByte instead of our own for loop.
      
      Change-Id: Ic4a1161d79017fd3af086a05c53d5f20a5f09326
      Reviewed-on: https://go-review.googlesource.com/54752Reviewed-by: 's avatarAvelino <t@avelino.xxx>
      Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
      Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
      1d812515
  2. 12 Aug, 2017 4 commits
  3. 11 Aug, 2017 30 commits
  4. 10 Aug, 2017 3 commits