1. 20 Feb, 2013 1 commit
    • Rob Pike's avatar
      bufio: new Scanner interface · 55ad7b9b
      Rob Pike authored
      Add a new, simple interface for scanning (probably textual) data,
      based on a new type called Scanner. It does its own internal buffering,
      so should be plausibly efficient even without injecting a bufio.Reader.
      The format of the input is defined by a "split function", by default
      splitting into lines. Other implemented split functions include single
      bytes, single runes, and space-separated words.
      
      Here's the loop to scan stdin as a file of lines:
      
              s := bufio.NewScanner(os.Stdin)
              for s.Scan() {
                      fmt.Printf("%s\n", s.Bytes())
              }
              if s.Err() != nil {
                      log.Fatal(s.Err())
              }
      
      While we're dealing with spaces, define what space means to strings.Fields.
      
      Fixes #4802.
      
      R=adg, rogpeppe, bradfitz, rsc
      CC=golang-dev
      https://golang.org/cl/7322088
      55ad7b9b
  2. 19 Feb, 2013 1 commit
    • Donovan Hide's avatar
      strings: faster Count, Index · 937f91e1
      Donovan Hide authored
      Slightly better benchmarks for when string and separator are equivalent and also less branching in inner loops.
      benchmark                        old ns/op    new ns/op    delta
      BenchmarkGenericNoMatch               3430         3442   +0.35%
      BenchmarkGenericMatch1               23590        22855   -3.12%
      BenchmarkGenericMatch2              108031       105025   -2.78%
      BenchmarkSingleMaxSkipping            2969         2704   -8.93%
      BenchmarkSingleLongSuffixFail         2826         2572   -8.99%
      BenchmarkSingleMatch                205268       197832   -3.62%
      BenchmarkByteByteNoMatch               987          921   -6.69%
      BenchmarkByteByteMatch                2014         1749  -13.16%
      BenchmarkByteStringMatch              3083         3050   -1.07%
      BenchmarkHTMLEscapeNew                 922          915   -0.76%
      BenchmarkHTMLEscapeOld                1654         1570   -5.08%
      BenchmarkByteByteReplaces            11897        11556   -2.87%
      BenchmarkByteByteMap                  4485         4255   -5.13%
      BenchmarkIndexRune                     174          121  -30.46%
      BenchmarkIndexRuneFastPath              41           41   -0.24%
      BenchmarkIndex                          45           44   -0.22%
      BenchmarkMapNoChanges                  433          431   -0.46%
      BenchmarkIndexHard1                4015336      3316490  -17.40%
      BenchmarkIndexHard2                3976254      3395627  -14.60%
      BenchmarkIndexHard3                3973158      3378329  -14.97%
      BenchmarkCountHard1                4403549      3448512  -21.69%
      BenchmarkCountHard2                4387437      3413059  -22.21%
      BenchmarkCountHard3                4403891      3382661  -23.19%
      BenchmarkIndexTorture                28354        25864   -8.78%
      BenchmarkCountTorture                29625        27463   -7.30%
      BenchmarkFields                   38752040     39169840   +1.08%
      BenchmarkFieldsFunc               38797765     38888060   +0.23%
      
      benchmark                         old MB/s     new MB/s  speedup
      BenchmarkSingleMaxSkipping         3367.07      3697.62    1.10x
      BenchmarkSingleLongSuffixFail       354.51       389.47    1.10x
      BenchmarkSingleMatch                 73.07        75.82    1.04x
      BenchmarkFields                      27.06        26.77    0.99x
      BenchmarkFieldsFunc                  27.03        26.96    1.00x
      
      R=dave, fullung, remyoudompheng, rsc
      CC=golang-dev
      https://golang.org/cl/7350045
      937f91e1
  3. 17 Feb, 2013 1 commit
    • Rémy Oudompheng's avatar
      strings: better mean complexity for Count and Index. · 23093f86
      Rémy Oudompheng authored
      The O(n+m) complexity is obtained probabilistically
      by using Rabin-Karp algorithm, which provides the needed complexity
      unless exceptional collisions occur, without memory allocation.
      
      benchmark                 old ns/op    new ns/op    delta
      BenchmarkIndexHard1         6532331      4045886  -38.06%
      BenchmarkIndexHard2         8178173      4038975  -50.61%
      BenchmarkIndexHard3         6973687      4042591  -42.03%
      BenchmarkCountHard1         6270864      4071090  -35.08%
      BenchmarkCountHard2         7838039      4072853  -48.04%
      BenchmarkCountHard3         6697828      4071964  -39.20%
      BenchmarkIndexTorture       2730546        28934  -98.94%
      BenchmarkCountTorture       2729622        29064  -98.94%
      
      Fixes #4600.
      
      R=rsc, donovanhide, remyoudompheng
      CC=golang-dev
      https://golang.org/cl/7314095
      23093f86
  4. 01 Feb, 2013 1 commit
  5. 09 Dec, 2011 1 commit
  6. 24 Nov, 2011 1 commit
  7. 08 Nov, 2011 1 commit
  8. 26 Oct, 2011 1 commit
  9. 26 Sep, 2011 2 commits
  10. 14 Jul, 2011 1 commit
  11. 27 Jun, 2011 1 commit
  12. 19 Apr, 2011 1 commit
  13. 29 Mar, 2011 1 commit
  14. 28 Mar, 2011 1 commit
  15. 08 Mar, 2011 1 commit
  16. 05 Jan, 2011 1 commit
  17. 30 Nov, 2010 1 commit
  18. 12 Nov, 2010 1 commit
  19. 01 Nov, 2010 1 commit
  20. 27 Oct, 2010 1 commit
  21. 23 Sep, 2010 1 commit
  22. 22 Sep, 2010 1 commit
  23. 05 Aug, 2010 1 commit
  24. 03 Aug, 2010 1 commit
  25. 27 Jul, 2010 1 commit
  26. 23 Jul, 2010 1 commit
  27. 20 Jul, 2010 1 commit
    • Rob Pike's avatar
      strings: add Title · 8684a089
      Rob Pike authored
      strings.ToTitle converts all characters to title case, which for consistency with the
      other To* functions it should continue to do.  This CL adds string.Title, which
      does a proper title-casing of the string.
      A similar function for package bytes will follow once this is settled.
      Fixes #933.
      
      R=rsc
      CC=golang-dev
      https://golang.org/cl/1869042
      8684a089
  28. 01 Jul, 2010 2 commits
  29. 14 Jun, 2010 1 commit
  30. 05 May, 2010 1 commit
  31. 19 Apr, 2010 1 commit
  32. 10 Apr, 2010 1 commit
  33. 31 Mar, 2010 1 commit
  34. 29 Mar, 2010 1 commit
  35. 26 Mar, 2010 1 commit
  36. 05 Mar, 2010 1 commit
  37. 26 Feb, 2010 1 commit
  38. 25 Feb, 2010 1 commit