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

Improve handler efficience with a map #91

Open
scallopedllama opened this issue Jul 11, 2018 · 2 comments
Open

Improve handler efficience with a map #91

scallopedllama opened this issue Jul 11, 2018 · 2 comments

Comments

@scallopedllama
Copy link

Browsing the code, it looks like the Page Handlers cascade by calling the handle() function in all of the handlers in its vector. The first thing this handler does is check if the cracked uri portion matches its part and return unhandled() if it does not match.

Could this be made more efficient by storing the handlers as a map of URI portion -> handler so that when a request comes in, the handler can crack off part of the url and call the handle method on all of the handlers inserted into the map under the key matching that map?

It's definitely possible I am misunderstanding the code so please correct me if I'm mistaken.

@mattgodbolt
Copy link
Owner

Thanks for taking a look at Seasocks!

The handle() function may choose to take an action (e.g. annotate the request with user information) without handling the request. This cascade allows things like authentication handlers to run "high up", and/or hierarchical page handling to be handled later on.

I agree it's not very efficient, but even in the most complex Seasocks setups I've used there's never more than a dozen handlers: iterating over them is not a real bottleneck.

@scallopedllama
Copy link
Author

Good point! Thanks for the info, I won't worry about this unless it proves to be a bottleneck

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