File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed
rxjava-core/src/main/java/rx Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change 2121import java .util .Arrays ;
2222import java .util .Comparator ;
2323import java .util .List ;
24+ import java .util .concurrent .ConcurrentHashMap ;
2425import java .util .concurrent .Future ;
2526import java .util .concurrent .TimeUnit ;
2627
129130 */
130131public class Observable <T > {
131132
133+ private final static ConcurrentHashMap <Class , Boolean > internalClassMap = new ConcurrentHashMap <Class , Boolean >();
134+
132135 /**
133136 * Executed when 'subscribe' is invoked.
134137 */
@@ -4545,11 +4548,21 @@ private boolean isInternalImplementation(Object o) {
45454548 return true ;
45464549 }
45474550 // prevent double-wrapping (yeah it happens)
4548- if (o instanceof SafeObserver )
4551+ if (o instanceof SafeObserver ) {
45494552 return true ;
4550- // we treat the following package as "internal" and don't wrap it
4551- Package p = o .getClass ().getPackage (); // it can be null
4552- return p != null && p .getName ().startsWith ("rx.operators" );
4553+ }
4554+
4555+ Class <?> clazz = o .getClass ();
4556+ if (internalClassMap .containsKey (clazz )) {
4557+ //don't need to do reflection
4558+ return internalClassMap .get (clazz );
4559+ } else {
4560+ // we treat the following package as "internal" and don't wrap it
4561+ Package p = o .getClass ().getPackage (); // it can be null
4562+ Boolean isInternal = (p != null && p .getName ().startsWith ("rx.operators" ));
4563+ internalClassMap .put (clazz , isInternal );
4564+ return isInternal ;
4565+ }
45534566 }
45544567
45554568}
You can’t perform that action at this time.
0 commit comments