Skip to content

Commit e214c23

Browse files
committed
Use underscores in numeric literals for improved readability
#2429
1 parent 0859fbd commit e214c23

16 files changed

Lines changed: 57 additions & 57 deletions

bench_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -641,35 +641,35 @@ func BenchmarkWrite100RowsViaCopy(b *testing.B) {
641641
}
642642

643643
func BenchmarkWrite1000RowsViaInsert(b *testing.B) {
644-
benchmarkWriteNRowsViaInsert(b, 1000)
644+
benchmarkWriteNRowsViaInsert(b, 1_000)
645645
}
646646

647647
func BenchmarkWrite1000RowsViaMultiInsert(b *testing.B) {
648-
benchmarkWriteNRowsViaMultiInsert(b, 1000)
648+
benchmarkWriteNRowsViaMultiInsert(b, 1_000)
649649
}
650650

651651
func BenchmarkWrite1000RowsViaBatchInsert(b *testing.B) {
652-
benchmarkWriteNRowsViaBatchInsert(b, 1000)
652+
benchmarkWriteNRowsViaBatchInsert(b, 1_000)
653653
}
654654

655655
func BenchmarkWrite1000RowsViaCopy(b *testing.B) {
656-
benchmarkWriteNRowsViaCopy(b, 1000)
656+
benchmarkWriteNRowsViaCopy(b, 1_000)
657657
}
658658

659659
func BenchmarkWrite10000RowsViaInsert(b *testing.B) {
660-
benchmarkWriteNRowsViaInsert(b, 10000)
660+
benchmarkWriteNRowsViaInsert(b, 10_000)
661661
}
662662

663663
func BenchmarkWrite10000RowsViaMultiInsert(b *testing.B) {
664-
benchmarkWriteNRowsViaMultiInsert(b, 10000)
664+
benchmarkWriteNRowsViaMultiInsert(b, 10_000)
665665
}
666666

667667
func BenchmarkWrite10000RowsViaBatchInsert(b *testing.B) {
668-
benchmarkWriteNRowsViaBatchInsert(b, 10000)
668+
benchmarkWriteNRowsViaBatchInsert(b, 10_000)
669669
}
670670

671671
func BenchmarkWrite10000RowsViaCopy(b *testing.B) {
672-
benchmarkWriteNRowsViaCopy(b, 10000)
672+
benchmarkWriteNRowsViaCopy(b, 10_000)
673673
}
674674

675675
func BenchmarkMultipleQueriesNonBatchNoStatementCache(b *testing.B) {

conn_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ func TestListenNotifyWhileBusyIsSafe(t *testing.T) {
795795

796796
<-listening
797797

798-
for range 100000 {
798+
for range 100_000 {
799799
mustExec(t, conn, "notify busysafe, 'hello'")
800800
}
801801
}()

copy_from_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func TestConnCopyFromLarge(t *testing.T) {
283283

284284
inputRows := [][]any{}
285285

286-
for range 10000 {
286+
for range 10_000 {
287287
inputRows = append(inputRows, []any{int16(0), int32(1), int64(2), "abc", "efg", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), tzedTime, []byte{111, 111, 111, 111}})
288288
}
289289

@@ -467,7 +467,7 @@ func (cfs *clientFailSource) Values() ([]any, error) {
467467
cfs.err = fmt.Errorf("client error")
468468
return nil, cfs.err
469469
}
470-
return []any{make([]byte, 100000)}, nil
470+
return []any{make([]byte, 100_000)}, nil
471471
}
472472

473473
func (cfs *clientFailSource) Err() error {
@@ -546,7 +546,7 @@ func (fs *failSource) Values() ([]any, error) {
546546
if fs.count == 3 {
547547
return []any{nil}, nil
548548
}
549-
return []any{make([]byte, 100000)}, nil
549+
return []any{make([]byte, 100_000)}, nil
550550
}
551551

552552
func (fs *failSource) Err() error {
@@ -717,7 +717,7 @@ func (cfs *clientFinalErrSource) Next() bool {
717717
}
718718

719719
func (cfs *clientFinalErrSource) Values() ([]any, error) {
720-
return []any{make([]byte, 100000)}, nil
720+
return []any{make([]byte, 100_000)}, nil
721721
}
722722

723723
func (cfs *clientFinalErrSource) Err() error {

internal/iobufpool/iobufpool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestPutHandlesWrongSizedBuffers(t *testing.T) {
7171
func TestPutGetBufferReuse(t *testing.T) {
7272
// There is no way to guarantee a buffer will be reused. It should be, but a GC between the Put and the Get will cause
7373
// it not to be. So try many times.
74-
for range 100000 {
74+
for range 100_000 {
7575
buf := iobufpool.Get(4)
7676
(*buf)[0] = 1
7777
iobufpool.Put(buf)

pgconn/ctxwatch/context_watcher_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func TestContextWatcherStress(t *testing.T) {
112112
},
113113
})
114114

115-
cycleCount := 100000
115+
cycleCount := 100_000
116116

117117
for i := range cycleCount {
118118
ctx, cancel := context.WithCancel(context.Background())

pgconn/pgconn_stress_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestConnStress(t *testing.T) {
1818
require.NoError(t, err)
1919
defer closeConn(t, pgConn)
2020

21-
actionCount := 10000
21+
actionCount := 10_000
2222
if s := os.Getenv("PGX_TEST_STRESS_FACTOR"); s != "" {
2323
stressFactor, err := strconv.ParseInt(s, 10, 64)
2424
require.Nil(t, err, "Failed to parse PGX_TEST_STRESS_FACTOR")

pgconn/pgconn_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ func TestConnExecBatchHuge(t *testing.T) {
16001600

16011601
batch := &pgconn.Batch{}
16021602

1603-
queryCount := 100000
1603+
queryCount := 100_000
16041604
args := make([]string, queryCount)
16051605

16061606
for i := range args {
@@ -2110,7 +2110,7 @@ func TestConnCopyFromCanceled(t *testing.T) {
21102110

21112111
r, w := io.Pipe()
21122112
go func() {
2113-
for i := range 1000000 {
2113+
for i := range 1_000_000 {
21142114
a := strconv.Itoa(i)
21152115
b := "foo " + a + " bar"
21162116
_, err := w.Write(fmt.Appendf(nil, "%s,\"%s\"\n", a, b))
@@ -2157,7 +2157,7 @@ func TestConnCopyFromPrecanceled(t *testing.T) {
21572157

21582158
r, w := io.Pipe()
21592159
go func() {
2160-
for i := range 1000000 {
2160+
for i := range 1_000_000 {
21612161
a := strconv.Itoa(i)
21622162
b := "foo " + a + " bar"
21632163
_, err := w.Write(fmt.Appendf(nil, "%s,\"%s\"\n", a, b))

pgproto3/backend.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ type Backend struct {
4646
}
4747

4848
const (
49-
minStartupPacketLen = 4 // minStartupPacketLen is a single 32-bit int version or code.
50-
maxStartupPacketLen = 10000 // maxStartupPacketLen is MAX_STARTUP_PACKET_LENGTH from PG source.
49+
minStartupPacketLen = 4 // minStartupPacketLen is a single 32-bit int version or code.
50+
maxStartupPacketLen = 10_000 // maxStartupPacketLen is MAX_STARTUP_PACKET_LENGTH from PG source.
5151
)
5252

5353
// NewBackend creates a new Backend.

pgproto3/chunkreader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestChunkReaderNextFuzz(t *testing.T) {
6565

6666
randomSizes := rand.New(rand.NewPCG(0, 0))
6767

68-
for range 100000 {
68+
for range 100_000 {
6969
size := randomSizes.IntN(16384) + 1
7070
buf, err := r.Next(size)
7171
if err != nil {

pgtype/interval.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
const (
14-
microsecondsPerSecond = 1000000
14+
microsecondsPerSecond = 1_000_000
1515
microsecondsPerMinute = 60 * microsecondsPerSecond
1616
microsecondsPerHour = 60 * microsecondsPerMinute
1717
microsecondsPerDay = 24 * microsecondsPerHour

0 commit comments

Comments
 (0)