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

lazy-seq seq ops require visit on every operation #265

Open
frenchy64 opened this issue Feb 13, 2025 · 1 comment
Open

lazy-seq seq ops require visit on every operation #265

frenchy64 opened this issue Feb 13, 2025 · 1 comment

Comments

@frenchy64
Copy link
Contributor

frenchy64 commented Feb 13, 2025

lazy_sequence's implementation uses runtime::{first,next,next_in_place} to traverse the inner seq, paying the cost of visit_seqable each step even though we know the inner seq's type once we call resolve_seq().

One idea might be to have resolve_seq() also cache the member functions of these operation as lambdas so the calls can be made directly.

  object_ptr lazy_sequence::first() const
  {
    resolve_seq();
    if(sequence)
    {
      // calls sequence->first() directly
      return cached_first(sequence);
    }
    return nil::nil_const();
  }

I'm also curious if there are other classes that have even longer "seq nesting".

@frenchy64
Copy link
Contributor Author

frenchy64 commented Feb 14, 2025

Another seq container class cons is a little different. Unlike lazy_sequence::next(), cons::next() returns the inner collection. This means the subsequent runtime::next() call won't need to also go through cons::next().

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

No branches or pull requests

1 participant