1
0
mirror of https://github.com/golang/go synced 2024-11-05 18:36:10 -07:00
Commit Graph

12 Commits

Author SHA1 Message Date
Rebecca Stambler
207d3de1fa all: fix some staticcheck errors
Updates golang/go#35718

Change-Id: I10bfd5421cd44bb58b8bcaa6e9205040c25f51be
Reviewed-on: https://go-review.googlesource.com/c/tools/+/208257
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2020-01-29 04:53:41 +00:00
Radu Berinde
1807494da8 x/tools/container/intsets: add LowerBound
Fixes golang/go#21310.

Change-Id: Id3f23a66b9889a5087c1f83e7d672d14c41a59e3
Reviewed-on: https://go-review.googlesource.com/53432
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-08-21 16:11:21 +00:00
Radu Berinde
43e94ff202 x/tools/container/intsets: use root block
The root block was used as a sentinel. This means we always need to
allocate a second block on the heap, even if the set has a few small
elements.

We now use the root block: it is always the block with the smallest
offset. The logic becomes very messy if there is no sentinel; to avoid
this we still use a sentinel (a special singleton block) and return it
in when appropriate in the first, last, next wrappers.

Also adding some benchmarks and making some optimizations:

name                           old time/op    new time/op    delta
Popcount-4                       2.18ns ± 1%    2.21ns ± 1%    +1.47%
InsertProbeSparse_2_10-4         76.2ns ±23%    37.2ns ± 1%   -51.21%
InsertProbeSparse_10_10-4         240ns ±15%     162ns ± 4%   -32.58%
InsertProbeSparse_10_1000-4       419ns ± 4%     371ns ±19%   -11.43%
InsertProbeSparse_100_100-4      2.30µs ± 1%    1.93µs ± 1%   -16.08%
InsertProbeSparse_100_10000-4    2.12µs ± 3%    2.07µs ± 1%    -2.11%
UnionDifferenceSparse-4           165µs ±16%     170µs ± 9%      ~
UnionDifferenceHashTable-4        310µs ±10%     291µs ±17%      ~
AppendTo-4                       11.0µs ± 0%    11.0µs ± 0%    -0.35%

name                           old alloc/op   new alloc/op   delta
Popcount-4                       0.00B ±NaN%    0.00B ±NaN%      ~
InsertProbeSparse_2_10-4          64.0B ± 0%     0.0B ±NaN%  -100.00%
InsertProbeSparse_10_10-4         64.0B ± 0%     0.0B ±NaN%  -100.00%
InsertProbeSparse_10_1000-4        256B ± 0%      192B ± 0%   -25.00%
InsertProbeSparse_100_100-4       64.0B ± 0%     0.0B ±NaN%  -100.00%
InsertProbeSparse_100_10000-4      256B ± 0%      192B ± 0%   -25.00%
UnionDifferenceSparse-4          59.4kB ± 0%    59.2kB ± 0%    -0.32%
UnionDifferenceHashTable-4        138kB ± 0%     138kB ± 0%      ~
AppendTo-4                       0.00B ±NaN%    0.00B ±NaN%      ~

name                           old allocs/op  new allocs/op  delta
Popcount-4                        0.00 ±NaN%     0.00 ±NaN%      ~
InsertProbeSparse_2_10-4           1.00 ± 0%     0.00 ±NaN%  -100.00%
InsertProbeSparse_10_10-4          1.00 ± 0%     0.00 ±NaN%  -100.00%
InsertProbeSparse_10_1000-4        4.00 ± 0%      3.00 ± 0%   -25.00%
InsertProbeSparse_100_100-4        1.00 ± 0%     0.00 ±NaN%  -100.00%
InsertProbeSparse_100_10000-4      4.00 ± 0%      3.00 ± 0%   -25.00%
UnionDifferenceSparse-4             928 ± 0%       925 ± 0%    -0.32%
UnionDifferenceHashTable-4          271 ± 0%       271 ± 0%      ~
AppendTo-4                        0.00 ±NaN%     0.00 ±NaN%      ~

Fixes golang/go#21311.

Change-Id: Ie472a2afa269c21cb33b22ffdac8dd2594b816ac
Reviewed-on: https://go-review.googlesource.com/53431
Reviewed-by: Alan Donovan <adonovan@google.com>
2017-08-21 15:22:10 +00:00
Andrew M Bursavich
ac8637e9fa container/intsets: Intersects, SubsetOf, SymmetricDifference(With)
Just reading through intsets and decided to knock out a few TODOs.

Change-Id: I677dbcc5ff934fbe0f0af09a4741e708a893f8db
Reviewed-on: https://go-review.googlesource.com/2733
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-01-14 20:51:28 +00:00
Emil Hessman
ca3901c3d8 all: address vet reports
Fixes various problems reported by go vet.

Change-Id: I12a6fdba8f911b21805d8e42903f8f6a5033790a
Reviewed-on: https://go-review.googlesource.com/2163
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-29 06:08:34 +00:00
Alan Donovan
b8d26f5b94 tools: minor comment fixes.
LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/173170043
2014-11-13 12:34:25 -05:00
Andrew Gerrand
5ebbcd132f go.tools: use golang.org/x/... import paths
Rewrite performed with this command:
  sed -i '' 's_code.google.com/p/go\._golang.org/x/_g' \
    $(grep -lr 'code.google.com/p/go.' *)

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/170920043
2014-11-10 08:50:40 +11:00
Alan Donovan
5fe8afcb15 container/intsets: add benchmark of AppendTo method.
Also:
- increase sparsity of sets in benchmarks.
- removed TODO in forEach.  Subword masks had no benefit.
- minor cleanup.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/103470049
2014-06-19 14:35:37 -04:00
Alan Donovan
65906ce503 go.tools/container/intsets: support negative elements in BitString().
(I forgot about this when we added support for negative elements generally.)

We use floating point for negative numbers.  The order of the
output is reversed from the previous (little-endian) behaviour
since it makes for more readable floating point.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/95570043
2014-05-20 14:52:50 -04:00
Rob Pike
6f17d00f0d go.tools: fix various minor issues found by go vet
LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/96360048
2014-05-19 08:47:28 -07:00
Alan Donovan
174d6e8ca3 go.tools/container/intsets: use " " not ", " as (*Sparse).String() separator.
This is both easier to read and 25% shorter (helpful when
using String() as a map key for interning sets).

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/96370045
2014-05-16 13:06:08 -04:00
Alan Donovan
61c5c64029 go.tools/container/intsets: Sparse: a space-efficient representation for ordered sets of int values.
intsets.Sparse is a sparse bit vector.  It uses space proportional
to the number of elements, not the maximum element (as is the case		for a dense bit vector).

A forthcoming CL will make use of it in go/pointer, where it reduces
solve time by 78%.  A similar representation is used for Andersen's
analysis in gcc and LLVM.

+ Tests.

LGTM=sameer, crawshaw, gri
R=gri
CC=crawshaw, golang-codereviews, sameer
https://golang.org/cl/10837043
2014-05-14 17:54:14 -04:00