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

Public split and improvements to visit speed #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Public split and improvements to visit speed #2

wants to merge 3 commits into from

Conversation

gburgett
Copy link

Hi,

I have a use case where we need to store timestamped data, split off everything before time.Now(), then iterate that split in ascending order in its entirety. I've made a couple improvements to the treap to accomplish this. Would you like to merge them back in?

The nil pivot short-circuit around the compare method was yielding about a 35% increase in performance for my particular use case. My comparison function is about as simple as you can compare timestamps:

func compare(a, b interface{}) int {
    pA := a.(myItem)
    pB := b.(myItem)

    if pA.Timestamp.Equal(pB.Timestamp) {
        return 0
    }
    if pA.Timestamp.Before(pB.Timestamp) {
        return -1
    }
    return 1
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant