Skip to content

Optimize deleteWordLeft loop iteration #1662

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

micic-mihajlo
Copy link

This PR optimizes the loop in deleteWordLeft that checks for word characters. Instead of iterating forward through all characters from 0 to cursor position, it now iterates backward from the cursor. This is more efficient since we can exit early when finding a word character.

The functionality remains unchanged - just the iteration direction.

Changed forward iteration to backward iteration when checking for word characters. This optimization reduces unnecessary iterations by checking characters from the cursor position backward instead of iterating through all characters from the start.

The functionality remains identical, but the performance is improved for cases where the cursor is far from the beginning of the line.
Copy link

github-actions bot commented Jul 23, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@micic-mihajlo
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Jul 23, 2025
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.

1 participant