// IsEqualGUID compares two GUID.
//
// Not constant time comparison.
345726
func IsEqualGUID(guid1 *GUID, guid2 *GUID) bool {
	return guid1.Data1 == guid2.Data1 &&
		guid1.Data2 == guid2.Data2 &&
		guid1.Data3 == guid2.Data3 &&
		guid1.Data4[0] == guid2.Data4[0] &&
		guid1.Data4[1] == guid2.Data4[1] &&
		guid1.Data4[2] == guid2.Data4[2] &&
		guid1.Data4[3] == guid2.Data4[3] &&
		guid1.Data4[4] == guid2.Data4[4] &&
		guid1.Data4[5] == guid2.Data4[5] &&
		guid1.Data4[6] == guid2.Data4[6] &&
		guid1.Data4[7] == guid2.Data4[7]
}
871456
func (e *Job) IsEqual(other *Job) bool {
	return e == other || (e.JobID == other.JobID &&
		e.ProjectID == other.ProjectID &&
		e.Flavor == other.Flavor &&
		e.Enabled == other.Enabled &&
		e.Paused == other.Paused &&
		e.Revision == other.Revision &&
		e.RevisionURL == other.RevisionURL &&
		e.Schedule == other.Schedule &&
		e.LastTriage.Equal(other.LastTriage) &&
		e.Acls.Equal(&other.Acls) &&
		bytes.Equal(e.Task, other.Task) &&
		equalSortedLists(e.TriggeredJobIDs, other.TriggeredJobIDs) &&
		e.Cron.Equal(&other.Cron) &&
		bytes.Equal(e.TriggeringPolicyRaw, other.TriggeringPolicyRaw) &&
		equalInt64Lists(e.ActiveInvocations, other.ActiveInvocations) &&
		bytes.Equal(e.FinishedInvocationsRaw, other.FinishedInvocationsRaw))
}
703256
func StringToGuid(guid string) (res [16]byte, err error) {
	byteOrder := [...]int{3, 2, 1, 0, -1, 5, 4, -1, 7, 6, -1, 8, 9, -1, 10, 11, 12, 13, 14, 15}
	if len(guid) != 36 {
		err = fmt.Errorf("BAD guid string length.")
		return
	}
	guidByteNum := 0
	for i := 0; i < len(guid); i += 2 {
		if byteOrder[guidByteNum] == -1 {
			if guid[i] == '-' {
				i++
				guidByteNum++
				if i >= len(guid)+1 {
					err = fmt.Errorf("BAD guid format minus")
					return
				}
			} else {
				err = fmt.Errorf("BAD guid char in minus pos")
				return
			}
		}

		sub := guid[i : i+2]
		var bt byte
		for pos, ch := range sub {
			var shift uint
			if pos == 0 {
				shift = 4
			} else {
				shift = 0
			}
			switch ch {
			case '0':
				bt |= 0 << shift
			case '1':
				bt |= 1 << shift
			case '2':
				bt |= 2 << shift
			case '3':
				bt |= 3 << shift
			case '4':
				bt |= 4 << shift
			case '5':
				bt |= 5 << shift
			case '6':
				bt |= 6 << shift
			case '7':
				bt |= 7 << shift
			case '8':
				bt |= 8 << shift
			case '9':
				bt |= 9 << shift
			case 'A', 'a':
				bt |= 10 << shift
			case 'B', 'b':
				bt |= 11 << shift
			case 'C', 'c':
				bt |= 12 << shift
			case 'D', 'd':
				bt |= 13 << shift
			case 'E', 'e':
				bt |= 14 << shift
			case 'F', 'f':
				bt |= 15 << shift
			default:
				err = fmt.Errorf("BAD guid char at pos %d: '%c'", i+pos, ch)
				return
			}
		}
		res[byteOrder[guidByteNum]] = bt
		guidByteNum++
	}
	return res, nil
}
1089851
func DistinctEqual(o1, o2 *DistinctOption) bool {
	if o1 != nil {
		return o1.Equal(o2)
	}
	if o2 != nil {
		return o2.Equal(o1)
	}
	return true
}
337791
func MinProximityEqual(o1, o2 *MinProximityOption) bool {
	if o1 != nil {
		return o1.Equal(o2)
	}
	if o2 != nil {
		return o2.Equal(o1)
	}
	return true
}
665247
func (gtidSet MariadbGTIDSet) Equal(other GTIDSet) bool {
	mdbOther, ok := other.(MariadbGTIDSet)
	if !ok {
		return false
	}
	if len(gtidSet) != len(mdbOther) {
		return false
	}
	for i, gtid := range gtidSet {
		if gtid != mdbOther[i] {
			return false
		}
	}
	return true
}
964900
func SteamIDsEqual(s1, s2 string) bool {
	c1, _ := SteamIdToCommId(s1)
	c2, _ := SteamIdToCommId(s2)

	return c1 == c2
}
646617
func GameControllerMappingForGUID(guid JoystickGUID) string {
	mappingString := C.SDL_GameControllerMappingForGUID(guid.c())
	defer C.free(unsafe.Pointer(mappingString))
	return C.GoString(mappingString)
}
290272
func RestrictIndicesEqual(o1, o2 *RestrictIndicesOption) bool {
	if o1 != nil {
		return o1.Equal(o2)
	}
	if o2 != nil {
		return o2.Equal(o1)
	}
	return true
}
185922
func Base58ToGuid(b58str string, inclHyphen bool) (string, error) {
	b58 := bitcoinmath.Base58(b58str)
	bi := b58.Base582Big()

	guid := fmt.Sprintf("%032s", bi.Text(16))

	if len(guid) != 32 {
		return "", fmt.Errorf("Error converting base58 string to hex: %v", b58str)
	}

	if inclHyphen {
		guid = rxGuid.ReplaceAllString(guid, guidReplace)
	}

	return guid, nil
}
466863
func (sig *Signature) IsEqual(otherSig *Signature) bool {
	return sig.R.Cmp(otherSig.R) == 0 &&
		sig.S.Cmp(otherSig.S) == 0
}
998835
func AutoGenerateObjectIDIfNotExistEqual(o1, o2 *AutoGenerateObjectIDIfNotExistOption) bool {
	if o1 != nil {
		return o1.Equal(o2)
	}
	if o2 != nil {
		return o2.Equal(o1)
	}
	return true
}
1359053
func (m *Migration) GetGUID() string {
	if m == nil || m.GUID == nil {
		return ""
	}
	return *m.GUID
}
85231
func (e *element) isEqual(e2 *element) bool {
	return (e.index == e2.index) &&
		(&e.hash).IsEqual(&e2.hash)
}
249416
func (e *ExponentialStrategy) IsEqual(o *ExponentialStrategy) bool {
	if e.opts.first != o.opts.first {
		return false
	}
	if e.opts.max != o.opts.max {
		return false
	}
	return true
}
360822
func IsEqual(data sort.Interface, pivot int) bool {
	k, l := pivot, data.Len()
	if k*2 != l {
		return false
	}
	for i := 0; i < k; i++ {
		p, q := k-i-1, l-i-1
		if data.Less(p, q) || data.Less(q, p) {
			return false
		}
	}
	return true
}
1074339
func (ref *Reference) IsEqual(other Query) bool {
	r := other.Ref()

	// check app instance
	if ref.database.app != r.database.app {
		return false
	}

	// check location
	if ref.path != r.path {
		return false
	}

	// check queries
	q1, q2 := url.Values{}, url.Values{}
	ref.buildQuery(q1)
	r.buildQuery(q2)
	if len(q1) != len(q2) || q1.Encode() != q2.Encode() {
		return false
	}

	return true
}