Skip to content

Commit 2a32ffb

Browse files
committed
remove “And” from geometry Add/Subtract helper names
1 parent 6aa8986 commit 2a32ffb

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

geometry.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ func (p Position) Add(v Vector2) Position {
4949
return Position{p.X + x, p.Y + y}
5050
}
5151

52-
// AddXAndY returns a new Position by adding x and y to the current one.
53-
func (p Position) AddXAndY(x, y float32) Position {
52+
// AddXY returns a new Position by adding x and y to the current one.
53+
func (p Position) AddXY(x, y float32) Position {
5454
return Position{p.X + x, p.Y + y}
5555
}
5656

@@ -71,8 +71,8 @@ func (p Position) Subtract(v Vector2) Position {
7171
return Position{p.X - x, p.Y - y}
7272
}
7373

74-
// SubtractXAndY returns a new Position by subtracting x and y from the current one.
75-
func (p Position) SubtractXAndY(x, y float32) Position {
74+
// SubtractXY returns a new Position by subtracting x and y from the current one.
75+
func (p Position) SubtractXY(x, y float32) Position {
7676
return Position{p.X - x, p.Y - y}
7777
}
7878

@@ -94,8 +94,8 @@ func (s Size) Add(v Vector2) Size {
9494
return Size{s.Width + w, s.Height + h}
9595
}
9696

97-
// AddWidthAndHeight returns a new Size by adding width and height to the current one.
98-
func (s Size) AddWidthAndHeight(width, height float32) Size {
97+
// AddWidthHeight returns a new Size by adding width and height to the current one.
98+
func (s Size) AddWidthHeight(width, height float32) Size {
9999
return Size{s.Width + width, s.Height + height}
100100
}
101101

@@ -136,7 +136,7 @@ func (s Size) Subtract(v Vector2) Size {
136136
return Size{s.Width - w, s.Height - h}
137137
}
138138

139-
// SubtractWidthAndHeight returns a new Size by subtracting width and height from the current one.
140-
func (s Size) SubtractWidthAndHeight(width, height float32) Size {
139+
// SubtractWidthHeight returns a new Size by subtracting width and height from the current one.
140+
func (s Size) SubtractWidthHeight(width, height float32) Size {
141141
return Size{s.Width - width, s.Height - height}
142142
}

geometry_benchmark_test.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,54 @@ import (
1212

1313
func BenchmarkPosition_Add(b *testing.B) {
1414
b.Run("Add()", benchmarkPositionAdd)
15-
b.Run("AddXAndY()", benchmarkPositionAddXAndY)
15+
b.Run("AddXY()", benchmarkPositionAddXY)
1616
}
1717

1818
func BenchmarkPosition_Subtract(b *testing.B) {
1919
b.Run("Subtract()", benchmarkPositionSubtract)
20-
b.Run("SubtractXAndY()", benchmarkPositionSubtractXAndY)
20+
b.Run("SubtractXY()", benchmarkPositionSubtractXY)
2121
}
2222

2323
func BenchmarkSize_Add(b *testing.B) {
2424
b.Run("Add()", benchmarkSizeAdd)
25-
b.Run("AddWidthAndHeight()", benchmarkSizeAddWidthAndHeight)
25+
b.Run("AddWidthHeight()", benchmarkSizeAddWidthHeight)
2626
}
2727

2828
func BenchmarkSize_Subtract(b *testing.B) {
2929
b.Run("Subtract()", benchmarkSizeSubtract)
30-
b.Run("SubtractWidthAndHeight()", benchmarkSizeSubtractWidthAndHeight)
30+
b.Run("SubtractWidthHeight()", benchmarkSizeSubtractWidthHeight)
3131
}
3232

33-
// This test prevents Position.Add to be simplified to `return p.AddXAndY(v.Components())`
33+
// This test prevents Position.Add to be simplified to `return p.AddXY(v.Components())`
3434
// because this slows down the speed by factor 10.
3535
func TestPosition_Add_Speed(t *testing.T) {
3636
add := testing.Benchmark(benchmarkPositionAdd)
37-
addXAndY := testing.Benchmark(benchmarkPositionAddXAndY)
38-
assert.Less(t, add.NsPerOp()/addXAndY.NsPerOp(), int64(5))
37+
addXY := testing.Benchmark(benchmarkPositionAddXY)
38+
assert.Less(t, add.NsPerOp()/addXY.NsPerOp(), int64(5))
3939
}
4040

41-
// This test prevents Position.Subtract to be simplified to `return p.SubtractXAndY(v.Components())`
41+
// This test prevents Position.Subtract to be simplified to `return p.SubtractXY(v.Components())`
4242
// because this slows down the speed by factor 10.
4343
func TestPosition_Subtract_Speed(t *testing.T) {
4444
subtract := testing.Benchmark(benchmarkPositionSubtract)
45-
subtractXAndY := testing.Benchmark(benchmarkPositionSubtractXAndY)
46-
assert.Less(t, subtract.NsPerOp()/subtractXAndY.NsPerOp(), int64(5))
45+
subtractXY := testing.Benchmark(benchmarkPositionSubtractXY)
46+
assert.Less(t, subtract.NsPerOp()/subtractXY.NsPerOp(), int64(5))
4747
}
4848

49-
// This test prevents Size.Add to be simplified to `return s.AddWidthAndHeight(v.Components())`
49+
// This test prevents Size.Add to be simplified to `return s.AddWidthHeight(v.Components())`
5050
// because this slows down the speed by factor 10.
5151
func TestSize_Add_Speed(t *testing.T) {
5252
add := testing.Benchmark(benchmarkSizeAdd)
53-
addWidthAndHeight := testing.Benchmark(benchmarkSizeAddWidthAndHeight)
54-
assert.Less(t, add.NsPerOp()/addWidthAndHeight.NsPerOp(), int64(5))
53+
addWidthHeight := testing.Benchmark(benchmarkSizeAddWidthHeight)
54+
assert.Less(t, add.NsPerOp()/addWidthHeight.NsPerOp(), int64(5))
5555
}
5656

57-
// This test prevents Size.Subtract to be simplified to `return s.SubtractWidthAndHeight(v.Components())`
57+
// This test prevents Size.Subtract to be simplified to `return s.SubtractWidthHeight(v.Components())`
5858
// because this slows down the speed by factor 10.
5959
func TestSize_Subtract_Speed(t *testing.T) {
6060
subtract := testing.Benchmark(benchmarkSizeSubtract)
61-
subtractWidthAndHeight := testing.Benchmark(benchmarkSizeSubtractWidthAndHeight)
62-
assert.Less(t, subtract.NsPerOp()/subtractWidthAndHeight.NsPerOp(), int64(5))
61+
subtractWidthHeight := testing.Benchmark(benchmarkSizeSubtractWidthHeight)
62+
assert.Less(t, subtract.NsPerOp()/subtractWidthHeight.NsPerOp(), int64(5))
6363
}
6464

6565
var benchmarkResult interface{}
@@ -72,10 +72,10 @@ func benchmarkPositionAdd(b *testing.B) {
7272
benchmarkResult = pos
7373
}
7474

75-
func benchmarkPositionAddXAndY(b *testing.B) {
75+
func benchmarkPositionAddXY(b *testing.B) {
7676
pos := fyne.NewPos(10, 10)
7777
for n := 0; n < b.N; n++ {
78-
pos = pos.AddXAndY(float32(n), float32(n))
78+
pos = pos.AddXY(float32(n), float32(n))
7979
}
8080
benchmarkResult = pos
8181
}
@@ -88,10 +88,10 @@ func benchmarkPositionSubtract(b *testing.B) {
8888
benchmarkResult = pos
8989
}
9090

91-
func benchmarkPositionSubtractXAndY(b *testing.B) {
91+
func benchmarkPositionSubtractXY(b *testing.B) {
9292
pos := fyne.NewPos(10, 10)
9393
for n := 0; n < b.N; n++ {
94-
pos = pos.SubtractXAndY(float32(n), float32(n))
94+
pos = pos.SubtractXY(float32(n), float32(n))
9595
}
9696
benchmarkResult = pos
9797
}
@@ -104,10 +104,10 @@ func benchmarkSizeAdd(b *testing.B) {
104104
benchmarkResult = size
105105
}
106106

107-
func benchmarkSizeAddWidthAndHeight(b *testing.B) {
107+
func benchmarkSizeAddWidthHeight(b *testing.B) {
108108
size := fyne.NewSize(10, 10)
109109
for n := 0; n < b.N; n++ {
110-
size = size.AddWidthAndHeight(float32(n), float32(n))
110+
size = size.AddWidthHeight(float32(n), float32(n))
111111
}
112112
benchmarkResult = size
113113
}
@@ -120,10 +120,10 @@ func benchmarkSizeSubtract(b *testing.B) {
120120
benchmarkResult = size
121121
}
122122

123-
func benchmarkSizeSubtractWidthAndHeight(b *testing.B) {
123+
func benchmarkSizeSubtractWidthHeight(b *testing.B) {
124124
size := fyne.NewSize(10, 10)
125125
for n := 0; n < b.N; n++ {
126-
size = size.SubtractWidthAndHeight(float32(n), float32(n))
126+
size = size.SubtractWidthHeight(float32(n), float32(n))
127127
}
128128
benchmarkResult = size
129129
}

geometry_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ func TestPosition_Add_Vector(t *testing.T) {
3737
assert.Equal(t, float32(35), pos2.Y)
3838
}
3939

40-
func TestPosition_AddXAndY(t *testing.T) {
40+
func TestPosition_AddXY(t *testing.T) {
4141
pos1 := fyne.NewPos(10, 10)
4242

43-
pos2 := pos1.AddXAndY(25, 25)
43+
pos2 := pos1.AddXY(25, 25)
4444

4545
assert.Equal(t, float32(35), pos2.X)
4646
assert.Equal(t, float32(35), pos2.Y)
@@ -73,10 +73,10 @@ func TestPosition_Subtract(t *testing.T) {
7373
assert.Equal(t, float32(15), pos3.Y)
7474
}
7575

76-
func TestPosition_SubtractXAndY(t *testing.T) {
76+
func TestPosition_SubtractXY(t *testing.T) {
7777
pos1 := fyne.NewPos(25, 25)
7878

79-
pos2 := pos1.SubtractXAndY(10, 10)
79+
pos2 := pos1.SubtractXY(10, 10)
8080

8181
assert.Equal(t, float32(15), pos2.X)
8282
assert.Equal(t, float32(15), pos2.Y)
@@ -112,10 +112,10 @@ func TestSize_Add_Vector(t *testing.T) {
112112
assert.Equal(t, float32(35), size2.Height)
113113
}
114114

115-
func TestSize_AddWidthAndHeight(t *testing.T) {
115+
func TestSize_AddWidthHeight(t *testing.T) {
116116
size1 := fyne.NewSize(10, 10)
117117

118-
size2 := size1.AddWidthAndHeight(25, 25)
118+
size2 := size1.AddWidthHeight(25, 25)
119119

120120
assert.Equal(t, float32(35), size2.Width)
121121
assert.Equal(t, float32(35), size2.Height)
@@ -168,10 +168,10 @@ func TestSize_Subtract(t *testing.T) {
168168
assert.Equal(t, float32(15), size3.Height)
169169
}
170170

171-
func TestSize_SubtractWidthAndHeight(t *testing.T) {
171+
func TestSize_SubtractWidthHeight(t *testing.T) {
172172
size1 := fyne.NewSize(25, 25)
173173

174-
size2 := size1.SubtractWidthAndHeight(10, 10)
174+
size2 := size1.SubtractWidthHeight(10, 10)
175175

176176
assert.Equal(t, float32(15), size2.Width)
177177
assert.Equal(t, float32(15), size2.Height)

0 commit comments

Comments
 (0)