Revision: d9b62c213e28
Author: Sam Berlin <[email protected]>
Date: Fri Jan 13 15:22:09 2012
Log: Do not create a new visitor instance for every call to
isSingleton.
Revision created by MOE tool push_codebase.
MOE_MIGRATION=4086
http://code.google.com/p/google-guice/source/detail?r=d9b62c213e28
Modified:
/core/src/com/google/inject/Scopes.java
=======================================
--- /core/src/com/google/inject/Scopes.java Fri Jan 13 15:21:27 2012
+++ /core/src/com/google/inject/Scopes.java Fri Jan 13 15:22:09 2012
@@ -120,17 +120,8 @@
}
};
- /**
- * Returns true if {@code binding} is singleton-scoped. If the binding
is a {@link
- * com.google.inject.spi.LinkedKeyBinding linked key binding} and
belongs to an injector (ie. it
- * was retrieved via {@link Injector#getBinding Injector.getBinding()}),
then this method will
- * also true if the target binding is singleton-scoped.
- *
- * @since 3.0
- */
- public static boolean isSingleton(Binding<?> binding) {
- do {
- boolean singleton = binding.acceptScopingVisitor(new
BindingScopingVisitor<Boolean>() {
+ private static final BindingScopingVisitor<Boolean> IS_SINGLETON_VISITOR
+ = new BindingScopingVisitor<Boolean>() {
public Boolean visitNoScoping() {
return false;
}
@@ -147,8 +138,19 @@
public Boolean visitEagerSingleton() {
return true;
}
- });
-
+ };
+
+ /**
+ * Returns true if {@code binding} is singleton-scoped. If the binding
is a {@link
+ * com.google.inject.spi.LinkedKeyBinding linked key binding} and
belongs to an injector (ie. it
+ * was retrieved via {@link Injector#getBinding Injector.getBinding()}),
then this method will
+ * also true if the target binding is singleton-scoped.
+ *
+ * @since 3.0
+ */
+ public static boolean isSingleton(Binding<?> binding) {
+ do {
+ boolean singleton =
binding.acceptScopingVisitor(IS_SINGLETON_VISITOR);
if (singleton) {
return true;
}
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice-dev?hl=en.