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

Heap-allocated loop index #10

Closed
dtolnay opened this issue Mar 6, 2017 · 1 comment
Closed

Heap-allocated loop index #10

dtolnay opened this issue Mar 6, 2017 · 1 comment

Comments

@dtolnay
Copy link
Contributor

dtolnay commented Mar 6, 2017

Maybe I don't understand the full scope of what it is solving, but this generated code looks like it could be a lot simpler and faster.

{% for inner in nested %}{% for _ in inner %}{% endfor %}{% endfor %}
let mut _loop_indexes = Vec::new();
let mut _loop_cur = 0;
_loop_indexes.push(0);
_loop_cur = 0;
for inner in (&self.nested).into_iter() {
    _loop_indexes[_loop_cur] += 1;
    _loop_indexes.push(0);
    _loop_cur = 1;
    for _ in (&inner).into_iter() {
        _loop_indexes[_loop_cur] += 1;
    }
    _loop_indexes.pop();
}
_loop_indexes.pop();

How about:

for (_index, inner) in (&self.nested).into_iter().enumerate() {
    for (_index, _) in (&inner).into_iter().enumerate() {
    }
}
@djc
Copy link
Owner

djc commented Mar 6, 2017

Yeah, it was kind of lazy. I guess this will fix #9, too.

@djc djc closed this as completed in 18735c9 Mar 6, 2017
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

2 participants