Skip to content

Commit f94016f

Browse files
committed
internal/proto: use protoregistry.Files.FindFileByPath
CL/182497 adds this new API. Change-Id: I14498a3b4ef295e8c9512e1a2ec10553915c7a92 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/182517 Reviewed-by: Damien Neil <[email protected]>
1 parent d3ac1a5 commit f94016f

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/golang/protobuf
22

33
go 1.9
44

5-
require google.golang.org/protobuf v0.0.0-20190617173324-378c1329ded0
5+
require google.golang.org/protobuf v0.0.0-20190617175724-bd7b7a9e0c26

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ google.golang.org/protobuf v0.0.0-20190516201745-40b83d67fc75/go.mod h1:jf+u8AHu
1212
google.golang.org/protobuf v0.0.0-20190516215540-a95b29fbf623/go.mod h1:cWWmz5lsCWIcqGLROrKq5Lu231IJw2PzqOZ8cgspbfY=
1313
google.golang.org/protobuf v0.0.0-20190522194032-21ade498bd69/go.mod h1:cJytyYi/6qdwy/+gD49hmgHcwD7zhWxE/1KPEslaZ3M=
1414
google.golang.org/protobuf v0.0.0-20190605195314-89d49632e5cf/go.mod h1:Btug4TBaP5wNYcb2zGKDTS7WMcaPPLuqEAKfEAZWYbo=
15-
google.golang.org/protobuf v0.0.0-20190617173324-378c1329ded0 h1:xWgajdfLzmZPasRoZwpEGv4W/ouKCE33vYT9lIhwXTI=
16-
google.golang.org/protobuf v0.0.0-20190617173324-378c1329ded0/go.mod h1:+FOB8T5/Yw4ywwdyeun9/KlDeuwFYBkNQ+kVuwj9C94=
15+
google.golang.org/protobuf v0.0.0-20190617175724-bd7b7a9e0c26 h1:TNW9FO1kBCrRCRWMg37SPUITvx76qDVlAja8TSVvX4c=
16+
google.golang.org/protobuf v0.0.0-20190617175724-bd7b7a9e0c26/go.mod h1:+FOB8T5/Yw4ywwdyeun9/KlDeuwFYBkNQ+kVuwj9C94=

internal/proto/registry.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ func FileDescriptor(s filePath) (d fileDescGZIP) {
7878
}
7979

8080
// Find the descriptor in the v2 registry.
81-
var n int
82-
protoregistry.GlobalFiles.RangeFilesByPath(s, func(fd pref.FileDescriptor) bool {
83-
n++
84-
85-
// Convert the structured file descriptor to the raw descriptor proto.
81+
if fd, _ := protoregistry.GlobalFiles.FindFileByPath(s); fd != nil {
8682
pb := protodesc.ToFileDescriptorProto(fd)
8783
b, err := protoV2.Marshal(pb)
8884
if err != nil {
@@ -97,10 +93,6 @@ func FileDescriptor(s filePath) (d fileDescGZIP) {
9793
panic(fmt.Sprintf("proto: compression failure: %v", err))
9894
}
9995
d = bb.Bytes()
100-
return true
101-
})
102-
if n > 1 {
103-
return d // best-effort; may be non-deterministic
10496
}
10597

10698
// Locally cache the raw descriptor form for the file.

0 commit comments

Comments
 (0)