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
128129 */
129130public class Observable <T > {
130131
132+ private final static ConcurrentHashMap <Class , Boolean > internalClassMap = new ConcurrentHashMap <Class , Boolean >();
133+
131134 /**
132135 * Executed when 'subscribe' is invoked.
133136 */
@@ -4522,11 +4525,21 @@ private boolean isInternalImplementation(Object o) {
45224525 return true ;
45234526 }
45244527 // prevent double-wrapping (yeah it happens)
4525- if (o instanceof SafeObserver )
4528+ if (o instanceof SafeObserver ) {
45264529 return true ;
4527- // we treat the following package as "internal" and don't wrap it
4528- Package p = o .getClass ().getPackage (); // it can be null
4529- return p != null && p .getName ().startsWith ("rx.operators" );
4530+ }
4531+
4532+ Class <?> clazz = o .getClass ();
4533+ if (internalClassMap .containsKey (clazz )) {
4534+ //don't need to do reflection
4535+ return internalClassMap .get (clazz );
4536+ } else {
4537+ // we treat the following package as "internal" and don't wrap it
4538+ Package p = o .getClass ().getPackage (); // it can be null
4539+ Boolean isInternal = (p != null && p .getName ().startsWith ("rx.operators" ));
4540+ internalClassMap .put (clazz , isInternal );
4541+ return isInternal ;
4542+ }
45304543 }
45314544
45324545}
You can’t perform that action at this time.
0 commit comments