@@ -127,14 +127,14 @@ private static final class DummyFilter extends Filter { }
127127 private static void filterUsingCallbacks (StringTrieSearch pathSearchTree ,
128128 Filter filter , List <StringFilterGroup > groups ,
129129 Filter .FilterContentType type ) {
130+ String filterSimpleName = filter .getClass ().getSimpleName ();
131+
130132 for (StringFilterGroup group : groups ) {
131133 if (!group .includeInSearch ()) {
132134 continue ;
133135 }
134136
135137 for (String pattern : group .filters ) {
136- String filterSimpleName = filter .getClass ().getSimpleName ();
137-
138138 pathSearchTree .addPattern (pattern , (textSearched , matchedStartIndex ,
139139 matchedLength , callbackParameter ) -> {
140140 if (!group .isEnabled ()) return false ;
@@ -162,6 +162,7 @@ private static void filterUsingCallbacks(StringTrieSearch pathSearchTree,
162162
163163 /**
164164 * Injection point. Called off the main thread.
165+ * Targets 20.22+
165166 */
166167 public static void setProtoBuffer (byte [] buffer ) {
167168 // Set the buffer to a thread local. The buffer will remain in memory, even after the call to #filter completes.
@@ -194,30 +195,30 @@ public static void setProtoBuffer(@Nullable ByteBuffer buffer) {
194195 */
195196 public static boolean isFiltered (String lithoIdentifier , StringBuilder pathBuilder ) {
196197 try {
198+ if (lithoIdentifier .isEmpty () && pathBuilder .length () == 0 ) {
199+ return false ;
200+ }
201+
197202 byte [] buffer = bufferThreadLocal .get ();
198203 // Potentially the buffer may have been null or never set up until now.
199204 // Use an empty buffer so the litho id/path filters still work correctly.
200205 if (buffer == null ) {
201206 buffer = EMPTY_BYTE_ARRAY ;
202207 }
203208
204- String path = pathBuilder . toString ();
205- LithoFilterParameters parameter = new LithoFilterParameters ( lithoIdentifier , path , buffer );
209+ LithoFilterParameters parameter = new LithoFilterParameters (
210+ lithoIdentifier , pathBuilder . toString () , buffer );
206211 Logger .printDebug (() -> "Searching " + parameter );
207212
208- if (path .isEmpty ()) {
209- // Identifier is filtered only if there is no path,
210- // meaning no component or sub components have been created yet.
211- if (identifierSearchTree .matches (parameter .identifier , parameter )) {
212- return true ;
213- }
214- } else {
215- if (pathSearchTree .matches (parameter .path , parameter )) {
216- return true ;
217- }
213+ if (identifierSearchTree .matches (parameter .identifier , parameter )) {
214+ return true ;
215+ }
216+
217+ if (pathSearchTree .matches (parameter .path , parameter )) {
218+ return true ;
218219 }
219220 } catch (Exception ex ) {
220- Logger .printException (() -> "Litho filter failure" , ex );
221+ Logger .printException (() -> "isFiltered failure" , ex );
221222 }
222223
223224 return false ;
0 commit comments