Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a profiler to improve linker performance #291

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ast/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type EnumValueDeclNode interface {
}

var _ EnumValueDeclNode = (*EnumValueNode)(nil)
var _ EnumValueDeclNode = NoSourceNode{}
var _ EnumValueDeclNode = (*NoSourceNode)(nil)

// EnumValueNode represents an enum declaration. Example:
//
Expand Down
4 changes: 2 additions & 2 deletions ast/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var _ FieldDeclNode = (*FieldNode)(nil)
var _ FieldDeclNode = (*GroupNode)(nil)
var _ FieldDeclNode = (*MapFieldNode)(nil)
var _ FieldDeclNode = (*SyntheticMapField)(nil)
var _ FieldDeclNode = NoSourceNode{}
var _ FieldDeclNode = (*NoSourceNode)(nil)

// FieldNode represents a normal field declaration (not groups or maps). It
// can represent extension fields as well as non-extension fields (both inside
Expand Down Expand Up @@ -394,7 +394,7 @@ type OneofDeclNode interface {

var _ OneofDeclNode = (*OneofNode)(nil)
var _ OneofDeclNode = (*SyntheticOneof)(nil)
var _ OneofDeclNode = NoSourceNode{}
var _ OneofDeclNode = (*NoSourceNode)(nil)

// OneofNode represents a one-of declaration. Example:
//
Expand Down
2 changes: 1 addition & 1 deletion ast/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type FileDeclNode interface {
}

var _ FileDeclNode = (*FileNode)(nil)
var _ FileDeclNode = NoSourceNode{}
var _ FileDeclNode = (*NoSourceNode)(nil)

// FileNode is the root of the AST hierarchy. It represents an entire
// protobuf source file.
Expand Down
2 changes: 1 addition & 1 deletion ast/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type MessageDeclNode interface {
var _ MessageDeclNode = (*MessageNode)(nil)
var _ MessageDeclNode = (*SyntheticGroupMessageNode)(nil)
var _ MessageDeclNode = (*SyntheticMapEntryNode)(nil)
var _ MessageDeclNode = NoSourceNode{}
var _ MessageDeclNode = (*NoSourceNode)(nil)

// MessageNode represents a message declaration. Example:
//
Expand Down
58 changes: 28 additions & 30 deletions ast/no_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,104 +41,102 @@ func (s unknownSpan) End() SourcePos {
// NoSourceNode is a placeholder AST node that implements numerous
// interfaces in this package. It can be used to represent an AST
// element for a file whose source is not available.
type NoSourceNode struct {
filename string
}
type NoSourceNode FileInfo

// NewNoSourceNode creates a new NoSourceNode for the given filename.
func NewNoSourceNode(filename string) NoSourceNode {
return NoSourceNode{filename: filename}
func NewNoSourceNode(filename string) *NoSourceNode {
return &NoSourceNode{name: filename}
}

func (n NoSourceNode) Name() string {
return n.filename
func (n *NoSourceNode) Name() string {
return n.name
}

func (n NoSourceNode) Start() Token {
func (n *NoSourceNode) Start() Token {
return 0
}

func (n NoSourceNode) End() Token {
func (n *NoSourceNode) End() Token {
return 0
}

func (n NoSourceNode) NodeInfo(Node) NodeInfo {
func (n *NoSourceNode) NodeInfo(Node) NodeInfo {
return NodeInfo{
fileInfo: &FileInfo{name: n.filename},
fileInfo: (*FileInfo)(n),
}
}

func (n NoSourceNode) GetSyntax() Node {
func (n *NoSourceNode) GetSyntax() Node {
return n
}

func (n NoSourceNode) GetName() Node {
func (n *NoSourceNode) GetName() Node {
return n
}

func (n NoSourceNode) GetValue() ValueNode {
func (n *NoSourceNode) GetValue() ValueNode {
return n
}

func (n NoSourceNode) FieldLabel() Node {
func (n *NoSourceNode) FieldLabel() Node {
return n
}

func (n NoSourceNode) FieldName() Node {
func (n *NoSourceNode) FieldName() Node {
return n
}

func (n NoSourceNode) FieldType() Node {
func (n *NoSourceNode) FieldType() Node {
return n
}

func (n NoSourceNode) FieldTag() Node {
func (n *NoSourceNode) FieldTag() Node {
return n
}

func (n NoSourceNode) FieldExtendee() Node {
func (n *NoSourceNode) FieldExtendee() Node {
return n
}

func (n NoSourceNode) GetGroupKeyword() Node {
func (n *NoSourceNode) GetGroupKeyword() Node {
return n
}

func (n NoSourceNode) GetOptions() *CompactOptionsNode {
func (n *NoSourceNode) GetOptions() *CompactOptionsNode {
return nil
}

func (n NoSourceNode) RangeStart() Node {
func (n *NoSourceNode) RangeStart() Node {
return n
}

func (n NoSourceNode) RangeEnd() Node {
func (n *NoSourceNode) RangeEnd() Node {
return n
}

func (n NoSourceNode) GetNumber() Node {
func (n *NoSourceNode) GetNumber() Node {
return n
}

func (n NoSourceNode) MessageName() Node {
func (n *NoSourceNode) MessageName() Node {
return n
}

func (n NoSourceNode) OneofName() Node {
func (n *NoSourceNode) OneofName() Node {
return n
}

func (n NoSourceNode) GetInputType() Node {
func (n *NoSourceNode) GetInputType() Node {
return n
}

func (n NoSourceNode) GetOutputType() Node {
func (n *NoSourceNode) GetOutputType() Node {
return n
}

func (n NoSourceNode) Value() interface{} {
func (n *NoSourceNode) Value() interface{} {
return nil
}

func (n NoSourceNode) RangeOptions(func(*OptionNode) bool) {
func (n *NoSourceNode) RangeOptions(func(*OptionNode) bool) {
}
4 changes: 2 additions & 2 deletions ast/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type OptionDeclNode interface {
}

var _ OptionDeclNode = (*OptionNode)(nil)
var _ OptionDeclNode = NoSourceNode{}
var _ OptionDeclNode = (*NoSourceNode)(nil)

// OptionNode represents the declaration of a single option for an element.
// It is used both for normal option declarations (start with "option" keyword
Expand Down Expand Up @@ -410,4 +410,4 @@ var _ NodeWithOptions = RPCDeclNode(nil)
var _ NodeWithOptions = FieldDeclNode(nil)
var _ NodeWithOptions = EnumValueDeclNode(nil)
var _ NodeWithOptions = (*ExtensionRangeNode)(nil)
var _ NodeWithOptions = NoSourceNode{}
var _ NodeWithOptions = (*NoSourceNode)(nil)
2 changes: 1 addition & 1 deletion ast/ranges.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type RangeDeclNode interface {
}

var _ RangeDeclNode = (*RangeNode)(nil)
var _ RangeDeclNode = NoSourceNode{}
var _ RangeDeclNode = (*NoSourceNode)(nil)

// RangeNode represents a range expression, used in both extension ranges and
// reserved ranges. Example:
Expand Down
2 changes: 1 addition & 1 deletion ast/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type RPCDeclNode interface {
}

var _ RPCDeclNode = (*RPCNode)(nil)
var _ RPCDeclNode = NoSourceNode{}
var _ RPCDeclNode = (*NoSourceNode)(nil)

// RPCNode represents an RPC declaration. Example:
//
Expand Down
2 changes: 1 addition & 1 deletion ast/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ ValueNode = (*SpecialFloatLiteralNode)(nil)
var _ ValueNode = (*SignedFloatLiteralNode)(nil)
var _ ValueNode = (*ArrayLiteralNode)(nil)
var _ ValueNode = (*MessageLiteralNode)(nil)
var _ ValueNode = NoSourceNode{}
var _ ValueNode = (*NoSourceNode)(nil)

// StringValueNode is an AST node that represents a string literal.
// Such a node can be a single literal (*StringLiteralNode) or a
Expand Down
Loading
Loading