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

optimize head/tail #70

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

Conversation

dur-randir
Copy link
Contributor

Seeing e559254, I couldn't pass. This greatly speeds it up and cuts code to half from the original.

XSRETURN( end - start );
while (--size >= 0) {
++SP;
*SP = *(SP + start);
Copy link
Contributor

@leonerd leonerd Nov 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. This is quite the change of behaviour - we're now returning aliases of the original input list, rather than new temporary SVs that copy it. This would have a change of behaviour in lvalue context; for example

my @n = (1 .. 10);
$_++ for tail 4, @n;

I'm undecided if that's a good thing or not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If such code wouldn't work before, I'd say this would just be a new feature...

Copy link
Contributor

@leonerd leonerd Nov 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be considered a feature yes. But it's a somewhat surprising change of behaviour. Is there a chance of accidental collateral damage?


I've asked for further opinion on p5p@ since it's a core module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning aliases is the behavior I would expect.

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.

4 participants