Skip to content

Commit e98ce2f

Browse files
authored
Optimize Service Container generation (#649)
## Context Before this PR, each service would get its own lazy ivar within the service container. If a service depended on another service then, it would reference that dep's getter. This allowed it to lazily instantiate all its deps as needed. However in some cases a service may not be used, or may only be used once. In both cases, that service doesn't need to have its own ivar. This PR optimizes the service container to not generate ivars for those kind of services. Services that are not used at all are just now not included in the container at all. Services that are used once are simply inlined into the getter of the service that needs it, however nested they are. For the `framework` component, this ultimately brings the service ivars from 36, down to just 14. This'll be just a bit less code to compile, and maybe make the GC's job a bit easier. ## Changelog - Do not generate ivars for unused services - Inline services where possible
1 parent 6d8196a commit e98ce2f

16 files changed

Lines changed: 1040 additions & 45 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
project: dependency-injection
2+
kind: Changed
3+
body: Reduce the amount of ivars within `ADI::ServiceContainer`
4+
time: 2025-12-31T13:06:54.806828708-05:00
5+
custom:
6+
Author: George Dietrich
7+
Breaking: "No"
8+
PR: "649"
9+
Username: blacksmoke16

0 commit comments

Comments
 (0)