Passed
Pull Request — master (#1486)
by
unknown
02:38
created

postgres.isSameArray   A

Complexity

Conditions 4

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 13
nop 2
dl 0
loc 20
rs 9.75
c 0
b 0
f 0
1
package postgres
2
3
import "sort"
4
5
const (
6
	RelationTuplesTable   = "relation_tuples"
7
	AttributesTable       = "attributes"
8
	SchemaDefinitionTable = "schema_definitions"
9
	TransactionsTable     = "transactions"
10
	TenantsTable          = "tenants"
11
	BundlesTable          = "bundles"
12
)
13
14
// isSameArray - check if two arrays are the same
15
func isSameArray(a, b []string) bool {
16
	if len(a) != len(b) {
17
		return false
18
	}
19
20
	sortedA := make([]string, len(a))
21
	copy(sortedA, a)
22
	sort.Strings(sortedA)
23
24
	sortedB := make([]string, len(b))
25
	copy(sortedB, b)
26
	sort.Strings(sortedB)
27
28
	for i := range sortedA {
29
		if sortedA[i] != sortedB[i] {
30
			return false
31
		}
32
	}
33
34
	return true
35
}
36