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

Initiative of simplifying logic of Each/Count #360

Open
uselessgoddess opened this issue Jul 26, 2022 · 1 comment
Open

Initiative of simplifying logic of Each/Count #360

uselessgoddess opened this issue Jul 26, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@uselessgoddess
Copy link
Member

In current implementation:

function CountBase {
    if query.Len == 0 {
        ...
    }

    if query.Len == 1 {
        ...
    }

    if query.Len == 2 {
        ...
    }
    . . . .
}

I suggest impl CountBase only for query of link size:

function CountBase {
    assert query.Len == 3
    . . . .
}

function CountExt {
    match query {
        [] => CountBase([Any, Any, Any])
        . . . .
        [id, from_id, to_id, ..] => CountBase([id, from_id, to_id])
    }
}

Also, i recommend add more complex logic for CountBase([Value, Value]). Anything that is more complicated than if or completely reject it query

@uselessgoddess uselessgoddess added the enhancement New feature or request label Jul 26, 2022
@uselessgoddess uselessgoddess changed the title I suggest simplifying the logic of Each/Count from StorageBase Simplifying logic of Each/Count initiative Jul 28, 2022
@uselessgoddess uselessgoddess changed the title Simplifying logic of Each/Count initiative Initiative of simplifying logic of Each/Count Jul 28, 2022
@uselessgoddess uselessgoddess pinned this issue Jul 28, 2022
@Konard
Copy link
Member

Konard commented Jul 28, 2022

I like the idea of simplification of logic to use only query.Len == 3 this will lead to smaller code and should make it even faster. This also removes the confusion about API, because Len == 1 or Len == 2 is closer to undefined behavior. We can try to make a benchmark of memory regular memory manager and simplified one to check how much performance gain we will get.

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

No branches or pull requests

2 participants