Skip to content

Commit 7c4d5bf

Browse files
committed
Use int instead of *int in functions which do not need to update it's value
1 parent 68825b4 commit 7c4d5bf

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

common_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func TestQueueEmptyWhenCreated(t *testing.T) {
1212
}
1313

1414
func TestQueueNowEmptyAfterAdd(t *testing.T) {
15-
queue := newPriorityQueue(0)
15+
queue := newPriorityQueue(1)
1616

1717
queue.Push(&pItem{
1818
v: 0,
@@ -25,7 +25,7 @@ func TestQueueNowEmptyAfterAdd(t *testing.T) {
2525
}
2626

2727
func TestQueueReturnsInPriorityOrder(t *testing.T) {
28-
queue := newPriorityQueue(0)
28+
queue := newPriorityQueue(2)
2929

3030
var (
3131
itemOne = &pItem{
@@ -55,7 +55,7 @@ func TestQueueReturnsInPriorityOrder(t *testing.T) {
5555
}
5656

5757
func TestQueueReturnsInPriorityOrderAfterUpdate(t *testing.T) {
58-
queue := newPriorityQueue(0)
58+
queue := newPriorityQueue(2)
5959

6060
var (
6161
itemOne = &pItem{

optics.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ func (c *opticsClusterer) run() {
190190

191191
c.so = append(c.so, i)
192192

193-
if d = c.coreDistance(i, &l, &ns); d != 0 {
193+
if d = c.coreDistance(i, l, &ns); d != 0 {
194194
q = newPriorityQueue(l)
195195

196-
c.update(i, d, &l, &ns, &q)
196+
c.update(i, d, l, &ns, &q)
197197

198198
for q.NotEmpty() {
199199
p = q.Pop().(*pItem)
@@ -204,22 +204,22 @@ func (c *opticsClusterer) run() {
204204

205205
c.so = append(c.so, p.v)
206206

207-
if d = c.coreDistance(p.v, &l, &nss); d != 0 {
208-
c.update(p.v, d, &l, &nss, &q)
207+
if d = c.coreDistance(p.v, l, &nss); d != 0 {
208+
c.update(p.v, d, l, &nss, &q)
209209
}
210210
}
211211
}
212212
}
213213
}
214214

215-
func (c *opticsClusterer) coreDistance(p int, l *int, r *[]int) float64 {
216-
if *l < c.minpts {
215+
func (c *opticsClusterer) coreDistance(p int, l int, r *[]int) float64 {
216+
if l < c.minpts {
217217
return 0
218218
}
219219

220220
var d, m float64 = 0, c.distance(c.d[p], c.d[(*r)[0]])
221221

222-
for i := 1; i < *l; i++ {
222+
for i := 1; i < l; i++ {
223223
if d = c.distance(c.d[p], c.d[(*r)[i]]); d > m {
224224
m = d
225225
}
@@ -228,8 +228,8 @@ func (c *opticsClusterer) coreDistance(p int, l *int, r *[]int) float64 {
228228
return m
229229
}
230230

231-
func (c *opticsClusterer) update(p int, d float64, l *int, r *[]int, q *priorityQueue) {
232-
for i := 0; i < *l; i++ {
231+
func (c *opticsClusterer) update(p int, d float64, l int, r *[]int, q *priorityQueue) {
232+
for i := 0; i < l; i++ {
233233
if !c.v[(*r)[i]] {
234234
m := math.Max(d, c.distance(c.d[p], c.d[(*r)[i]]))
235235

0 commit comments

Comments
 (0)