mirror of
https://github.com/go-gitea/gitea.git
synced 2024-08-31 16:47:44 +02:00
* update github.com/blevesearch/bleve v2.0.2 -> v2.0.3 * github.com/denisenkom/go-mssqldb v0.9.0 -> v0.10.0 * github.com/editorconfig/editorconfig-core-go v2.4.1 -> v2.4.2 * github.com/go-chi/cors v1.1.1 -> v1.2.0 * github.com/go-git/go-billy v5.0.0 -> v5.1.0 * github.com/go-git/go-git v5.2.0 -> v5.3.0 * github.com/go-ldap/ldap v3.2.4 -> v3.3.0 * github.com/go-redis/redis v8.6.0 -> v8.8.2 * github.com/go-sql-driver/mysql v1.5.0 -> v1.6.0 * github.com/go-swagger/go-swagger v0.26.1 -> v0.27.0 * github.com/lib/pq v1.9.0 -> v1.10.1 * github.com/mattn/go-sqlite3 v1.14.6 -> v1.14.7 * github.com/go-testfixtures/testfixtures v3.5.0 -> v3.6.0 * github.com/issue9/identicon v1.0.1 -> v1.2.0 * github.com/klauspost/compress v1.11.8 -> v1.12.1 * github.com/mgechev/revive v1.0.3 -> v1.0.6 * github.com/microcosm-cc/bluemonday v1.0.7 -> v1.0.8 * github.com/niklasfasching/go-org v1.4.0 -> v1.5.0 * github.com/olivere/elastic v7.0.22 -> v7.0.24 * github.com/pelletier/go-toml v1.8.1 -> v1.9.0 * github.com/prometheus/client_golang v1.9.0 -> v1.10.0 * github.com/xanzy/go-gitlab v0.44.0 -> v0.48.0 * github.com/yuin/goldmark v1.3.3 -> v1.3.5 * github.com/6543/go-version v1.2.4 -> v1.3.1 * do github.com/lib/pq v1.10.0 -> v1.10.1 again ...
90 lines
2.9 KiB
Go
Vendored
90 lines
2.9 KiB
Go
Vendored
// Copyright 2020 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package order
|
|
|
|
import (
|
|
pref "google.golang.org/protobuf/reflect/protoreflect"
|
|
)
|
|
|
|
// FieldOrder specifies the ordering to visit message fields.
|
|
// It is a function that reports whether x is ordered before y.
|
|
type FieldOrder func(x, y pref.FieldDescriptor) bool
|
|
|
|
var (
|
|
// AnyFieldOrder specifies no specific field ordering.
|
|
AnyFieldOrder FieldOrder = nil
|
|
|
|
// LegacyFieldOrder sorts fields in the same ordering as emitted by
|
|
// wire serialization in the github.com/golang/protobuf implementation.
|
|
LegacyFieldOrder FieldOrder = func(x, y pref.FieldDescriptor) bool {
|
|
ox, oy := x.ContainingOneof(), y.ContainingOneof()
|
|
inOneof := func(od pref.OneofDescriptor) bool {
|
|
return od != nil && !od.IsSynthetic()
|
|
}
|
|
|
|
// Extension fields sort before non-extension fields.
|
|
if x.IsExtension() != y.IsExtension() {
|
|
return x.IsExtension() && !y.IsExtension()
|
|
}
|
|
// Fields not within a oneof sort before those within a oneof.
|
|
if inOneof(ox) != inOneof(oy) {
|
|
return !inOneof(ox) && inOneof(oy)
|
|
}
|
|
// Fields in disjoint oneof sets are sorted by declaration index.
|
|
if ox != nil && oy != nil && ox != oy {
|
|
return ox.Index() < oy.Index()
|
|
}
|
|
// Fields sorted by field number.
|
|
return x.Number() < y.Number()
|
|
}
|
|
|
|
// NumberFieldOrder sorts fields by their field number.
|
|
NumberFieldOrder FieldOrder = func(x, y pref.FieldDescriptor) bool {
|
|
return x.Number() < y.Number()
|
|
}
|
|
|
|
// IndexNameFieldOrder sorts non-extension fields before extension fields.
|
|
// Non-extensions are sorted according to their declaration index.
|
|
// Extensions are sorted according to their full name.
|
|
IndexNameFieldOrder FieldOrder = func(x, y pref.FieldDescriptor) bool {
|
|
// Non-extension fields sort before extension fields.
|
|
if x.IsExtension() != y.IsExtension() {
|
|
return !x.IsExtension() && y.IsExtension()
|
|
}
|
|
// Extensions sorted by fullname.
|
|
if x.IsExtension() && y.IsExtension() {
|
|
return x.FullName() < y.FullName()
|
|
}
|
|
// Non-extensions sorted by declaration index.
|
|
return x.Index() < y.Index()
|
|
}
|
|
)
|
|
|
|
// KeyOrder specifies the ordering to visit map entries.
|
|
// It is a function that reports whether x is ordered before y.
|
|
type KeyOrder func(x, y pref.MapKey) bool
|
|
|
|
var (
|
|
// AnyKeyOrder specifies no specific key ordering.
|
|
AnyKeyOrder KeyOrder = nil
|
|
|
|
// GenericKeyOrder sorts false before true, numeric keys in ascending order,
|
|
// and strings in lexicographical ordering according to UTF-8 codepoints.
|
|
GenericKeyOrder KeyOrder = func(x, y pref.MapKey) bool {
|
|
switch x.Interface().(type) {
|
|
case bool:
|
|
return !x.Bool() && y.Bool()
|
|
case int32, int64:
|
|
return x.Int() < y.Int()
|
|
case uint32, uint64:
|
|
return x.Uint() < y.Uint()
|
|
case string:
|
|
return x.String() < y.String()
|
|
default:
|
|
panic("invalid map key type")
|
|
}
|
|
}
|
|
)
|