Skip to content

cmd/compile: remove badgerbadgerbadger optimization? #29242

@josharian

Description

@josharian

From walk.go:

func walkcompareString(n *Node, init *Nodes) *Node {
	// s + "badgerbadgerbadger" == "badgerbadgerbadger"
	if (n.Op == OEQ || n.Op == ONE) && Isconst(n.Right, CTSTR) && n.Left.Op == OADDSTR && n.Left.List.Len() == 2 && Isconst(n.Left.List.Second(), CTSTR) && strlit(n.Right) == strlit(n.Left.List.Second()) {
		r := nod(n.Op, nod(OLEN, n.Left.List.First(), nil), nodintconst(0))
		return finishcompare(n, r, init)
	}

	// cont...

I've always been skeptical that anyone writes code that matches this pattern; I'd like to remove it.

Thoughts/objections?

cc @mdempsky @randall77

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions