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

Merge uws.webserver_has_event with uws.webserver_get_next_event to eliminate useless function calls #203

Open
rdw-software opened this issue Jun 2, 2023 · 0 comments

Comments

@rdw-software
Copy link
Member

rdw-software commented Jun 2, 2023

The docs for uws.webserver_get_next_event state:

image

This seems like a minor issue with the design: Why can't the bindings just return false in this case (no copying), and true otherwise? Currently, the return type is void and this is done via webserver_has_event instead. Both of these can be merged.

The difference will likely be minor and I'd bet that LuaJIT can optimize this away, but removing a function would simplify the API.

TBD:

  • Is there ever a use case where you want to check that there are events in the buffer without fetching them afterwards?
  • Isn't webserver_get_event_count sufficient enough to check that there are events? Seems a bit redundant, if less clear

Since these are FFI bindings and not high-level APIs, simplifying the API surface should be more valuable than clarity of intent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Vague and distant future (Backlog)
Development

No branches or pull requests

1 participant