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

Add setMany proc #26

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

Add setMany proc #26

wants to merge 1 commit into from

Conversation

Nycto
Copy link
Collaborator

@Nycto Nycto commented Nov 19, 2023

This function is a faster way to set many pixels in a bitmap, as compared to individually setting each pixel, while still being safe. The speed comes from a few mechanisms:

  1. Centralized bounds checking
  2. Single read from getData
  3. Operating on reading and writing entire words instead of individual bits
  4. Separating iteration over the primary bitmap and the mask to improve cache hits
  5. ensuring that the input array is divisible by 8 to avoid any bounds checking within the loop

The big caveat is that I wrote this assuming the above mechanisms would be faster, but I didn't test each of those assertions separately. Nor have I examined the generated code. There is definitely still speed that can be wrought from this method if someone cares to tune it further. For example, there is definitely some unnecessary branching in the generated code that could probably be eliminated.

@Nycto Nycto mentioned this pull request Nov 19, 2023
@ninovanhooff
Copy link
Collaborator

What's holding this one up? I'd say it would be quite nice to tackle the one one advantage Lua has over Nim

@Nycto
Copy link
Collaborator Author

Nycto commented Apr 15, 2024

There has probably been some bit rot with this PR, and there may be some ideas about a better possible function signature.

@ninovanhooff ninovanhooff changed the base branch from main to dev October 25, 2024 11:28
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.

2 participants