goto setfalse
case OEQ<<16 | CTSTR:
- if cmpslit(nl, nr) == 0 {
+ if strlit(nl) == strlit(nr) {
goto settrue
}
goto setfalse
case ONE<<16 | CTSTR:
- if cmpslit(nl, nr) != 0 {
+ if strlit(nl) != strlit(nr) {
goto settrue
}
goto setfalse
case OLT<<16 | CTSTR:
- if cmpslit(nl, nr) < 0 {
+ if strlit(nl) < strlit(nr) {
goto settrue
}
goto setfalse
case OLE<<16 | CTSTR:
- if cmpslit(nl, nr) <= 0 {
+ if strlit(nl) <= strlit(nr) {
goto settrue
}
goto setfalse
case OGE<<16 | CTSTR:
- if cmpslit(nl, nr) >= 0 {
+ if strlit(nl) >= strlit(nr) {
goto settrue
}
goto setfalse
case OGT<<16 | CTSTR:
- if cmpslit(nl, nr) > 0 {
+ if strlit(nl) > strlit(nr) {
goto settrue
}
goto setfalse
Convlit(rp, Types[TINT])
}
-func cmpslit(l, r *Node) int {
- return stringsCompare(l.Val().U.(string), r.Val().U.(string))
+// strlit returns the value of a literal string Node as a string.
+func strlit(n *Node) string {
+ return n.Val().U.(string)
}
func Smallintconst(n *Node) bool {
}
// s + "badgerbadgerbadger" == "badgerbadgerbadger"
- if (n.Etype == OEQ || n.Etype == ONE) && Isconst(n.Right, CTSTR) && n.Left.Op == OADDSTR && count(n.Left.List) == 2 && Isconst(n.Left.List.Next.N, CTSTR) && cmpslit(n.Right, n.Left.List.Next.N) == 0 {
+ if (n.Etype == OEQ || n.Etype == ONE) && Isconst(n.Right, CTSTR) && n.Left.Op == OADDSTR && count(n.Left.List) == 2 && Isconst(n.Left.List.Next.N, CTSTR) && strlit(n.Right) == strlit(n.Left.List.Next.N) {
r := Nod(int(n.Etype), Nod(OLEN, n.Left.List.N, nil), Nodintconst(0))
typecheck(&r, Erv)
walkexpr(&r, init)