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

Needle should generate a alternate version of the generated code that's more runtime reliant #432

Open
rudro opened this issue Jul 20, 2022 · 1 comment

Comments

@rudro
Copy link
Collaborator

rudro commented Jul 20, 2022

The total volume of code needle produces is O(average_number_of_items_in_the_dependency_protocols x total_number_of_paths_in_the_component_tree). At Uber, the first one is slightly high maybe, but the second part is really high in our flagship apps. This is due to the total number of unique components being high and some nodes being repeated in many places.

Instead of such explicit code that we can rely on the Swift compiler to perform a second layer of safety checks for us with, we could create dictionaries at each component. Then we could rely on dynamic member lookup and then, at runtime, walk up the tree of components (to ancestors) and check on these dictionaries and check if the dictionary has the item we are looking for.

rudro added a commit that referenced this issue Jul 21, 2022
- Note all the changes are pretty much dead-code for now as they are guarded by #if statements

Start of implementation of #432
rudro added a commit that referenced this issue Jul 25, 2022
* Prep NeedleFoundation for dynamic code path

- Note all the changes are pretty much dead-code for now as they are guarded by #if statements

Start of implementation of #432

* Remove debug statements

* Add some initial documentation

- Both for the current generated code as well as the new dynamic path
rudro added a commit that referenced this issue Aug 19, 2022
- Code generated is guarded so current behavior is not affected
- Both paths are generated in the same file, the parsing of the `#if` should not slow things down
- Addresses #432
rudro added a commit that referenced this issue Aug 19, 2022
- Code generated is guarded so current behavior is not affected
- Both paths are generated in the same file, the parsing of the `#if` should not slow things down
- Addresses #432
rudro added a commit that referenced this issue Aug 29, 2022
* New Needle dynamic codepath

- Code generated is guarded so current behavior is not affected
- Both paths are generated in the same file, the parsing of the `#if` should not slow things down
- Addresses #432

* Fix header for one file
@haifengkao
Copy link

haifengkao commented Oct 22, 2022

Could you tell me how to use this feature? It's not in the doc yet.
It seems that I don't have to call register with this feature.

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