-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
parser/opcode: fix format function for mod opcode #7455
Conversation
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -134,5 +134,5 @@ var opsLiteral = map[Op]string{ | |||
|
|||
// Format the ExprNode into a Writer. | |||
func (o Op) Format(w io.Writer) { | |||
fmt.Fprintf(w, opsLiteral[o]) | |||
fmt.Fprintf(w, "%s", opsLiteral[o]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe w.Write([]byte(opsLiteral[o]))
is better? 0.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or make opsLiteral
be map[Op][]byte
then w.write(opsLiteral[o])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is still a memory allocation in w.Write([]byte(opsLiteral[o]))
when converting string to []byte.
If you want better performance, the 'hack' could be used, but I don't think it matters here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What problem does this PR solve?
Before this fix, format
Mod
opcode will get%!(NOVERB)
What is changed and how it works?
Use fmt.Printf correctly.
Check List
Tests
@lysu @jackysp