使用元标记或吸气剂注入更好/更快/更轻?动作脚本 3 / 柔性
我想知道哪一个更好/更快/更轻?
[Inject]
public var myInjection:MyInjection;
或者
[Inject]
public var injector:IInjector;
protected var _myInjection:MyInjection;
public function get myInjection():MyInjection{
if(!_myInjection) _myInjection = injector.getInstance(MyInjection);
return _myInjection;
}
?
I would like to know which one is better/faster/lighter?
[Inject]
public var myInjection:MyInjection;
OR
[Inject]
public var injector:IInjector;
protected var _myInjection:MyInjection;
public function get myInjection():MyInjection{
if(!_myInjection) _myInjection = injector.getInstance(MyInjection);
return _myInjection;
}
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那么第一个是合适的。第二个很奇怪。
您已经在几个问题中注入了 IInjector。在我构建的所有 Robotlegs 应用程序中,我从未需要注入注射器。我唯一需要这样做的时候是当我编写框架扩展/实用程序时。
well the first one is appropriate. The second is weird.
You've injected the IInjector in a couple of questions. In all of the robotlegs apps I've built I have never needed to inject the injector. The only time I've needed to do that is when I was writing framework extensions/utils.
我感觉第一个更快。 SwiftSuspenders 为每个注入者保留注入点的缓存 - 第二种方法可能不会利用该缓存。
I have a feeling that the first is faster. SwiftSuspenders keeps a cache of injection points for each injectee - the second method would probably not take advantage of that caching.