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

container/list: list.go, Are these places can do little optimization #10625

Closed
chanxuehong opened this issue Apr 30, 2015 · 1 comment
Closed

Comments

@chanxuehong
Copy link
Contributor

https://github.com/golang/go/blob/master/src/container/list/list.go#L185
https://github.com/golang/go/blob/master/src/container/list/list.go#L194

For MoveBefore, if e == mark.prev, we can do nothing,
MoveAfter also a reason

If I remember correctly, MoveBefore originally had such pr, also accepted, but not now how, and who can give me a reply

// MoveBefore moves element e to its new position before mark.
// If e or mark is not an element of l, or e == mark, the list is not modified.
func (l *List) MoveBefore(e, mark *Element) {
    if e.list != l || mark.list != l  || e == mark || e == mark.prev{
        return
    }
    l.insert(l.remove(e), mark.prev)
}

// MoveAfter moves element e to its new position after mark.
// If e or mark is not an element of l, or e == mark, the list is not modified.
func (l *List) MoveAfter(e, mark *Element) {
    if e.list != l || mark.list != l || e == mark || e == mark.next {
        return
    }
    l.insert(l.remove(e), mark)
}
@bradfitz
Copy link
Contributor

This is better discussed on the golang-dev@ mailing list. But unless there's a bug or major performance problem, we're unlikely to accept any changes to this code. This code is effectively frozen.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants