Open
Description
What did you see?
Conversions like
string([]byte{...})
[]byte("...")
are not constant folded.
What did you expect?
Conversions of const literals should probably be constant folded because it significantly slows down
things like
for .... {
p.Write([]byte(":=")
}
This is related to #26264 but the scope of that issues should probably be the difference between Write, WriteByte, WriteString
as some conversions not being constant folded is an issue on a different level that has little to do with the performance of these functions per se.
I can't quite tell whether []rune(...)
is also not constant folded because I'm not sure what type.[]int32
actually does but for []byte(...)
and string(...)
there are calls to runtime.stringtoslicebyte(SB)
and runtime.slicebytetostring(SB)
.
What version of Go are you using (go version
)?
1.10.3
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Triage Backlog