Source:
<code>public void postProcessOptimisation() { DefaultSrcDirective defaultSrcDirective; int directiveCount = this.directives.size(); if (directiveCount < 2) { return; } SourceListDirective prevDirective = null; int fetchDirectiveCount = 0; boolean isfetchSourceListIdentical = true; for (Map.Entry<Class<?>, Directive<? extends DirectiveValue>> entry : this.directives.entrySet()) { Directive<? extends DirectiveValue> directive = entry.getValue(); if (directive instanceof FetchDirective) { fetchDirectiveCount++; if (prevDirective != null) { if (!prevDirective.sourceListEquals(directive)) { isfetchSourceListIdentical = false; break; } } prevDirective = (SourceListDirective) directive; } } <START> if (fetchDirectiveCount == Directive.getFetchDirectives().size() && isfetchSourceListIdentical) { <END> Set<SourceExpression> combinedSources = prevDirective.values().collect(Collectors.toCollection(LinkedHashSet::new)); defaultSrcDirective = new DefaultSrcDirective(combinedSources); Directive.getFetchDirectives().forEach(x -> this.directives.remove(x)); this.directives.put(DefaultSrcDirective.class, defaultSrcDirective); } if (directiveCount == 2 && this.directives.containsKey(ScriptSrcDirective.class) && this.directives .containsKey(StyleSrcDirective.class)) { ScriptSrcDirective scriptSrcDirective = this.getDirectiveByType(ScriptSrcDirective.class); StyleSrcDirective styleSrcDirective = this.getDirectiveByType(StyleSrcDirective.class); if (scriptSrcDirective.sourceListEquals(styleSrcDirective) && scriptSrcDirective.containsKeywordsAndNoncesOnly()) { defaultSrcDirective = new DefaultSrcDirective(scriptSrcDirective.values().collect(Collectors.toCollection(LinkedHashSet::new))); this.directives.remove(ScriptSrcDirective.class); this.directives.remove(StyleSrcDirective.class); this.directives.put(DefaultSrcDirective.class, defaultSrcDirective); } } }</code><technical_language>Directive.getFetchDirectives().size() a constant Directive statically</technical_language>

Target:
public void postProcessOptimisation() { DefaultSrcDirective defaultSrcDirective; int directiveCount = this.directives.size(); if (directiveCount < 2) { return; } SourceListDirective prevDirective = null; int fetchDirectiveCount = 0; boolean isfetchSourceListIdentical = true; for (Map.Entry<Class<?>, Directive<? extends DirectiveValue>> entry : this.directives.entrySet()) { Directive<? extends DirectiveValue> directive = entry.getValue(); if (directive instanceof FetchDirective) { fetchDirectiveCount++; if (prevDirective != null) { if (!prevDirective.sourceListEquals(directive)) { isfetchSourceListIdentical = false; break; } } prevDirective = (SourceListDirective) directive; } } if (fetchDirectiveCount == Directive.FETCH_DIRECIVE_COUNT && isfetchSourceListIdentical) { Set<SourceExpression> combinedSources = prevDirective.values().collect(Collectors.toCollection(LinkedHashSet::new)); defaultSrcDirective = new DefaultSrcDirective(combinedSources); Directive.getFetchDirectives().forEach(x -> this.directives.remove(x)); this.directives.put(DefaultSrcDirective.class, defaultSrcDirective); } if (directiveCount == 2 && this.directives.containsKey(ScriptSrcDirective.class) && this.directives .containsKey(StyleSrcDirective.class)) { ScriptSrcDirective scriptSrcDirective = this.getDirectiveByType(ScriptSrcDirective.class); StyleSrcDirective styleSrcDirective = this.getDirectiveByType(StyleSrcDirective.class); if (scriptSrcDirective.sourceListEquals(styleSrcDirective) && scriptSrcDirective.containsKeywordsAndNoncesOnly()) { defaultSrcDirective = new DefaultSrcDirective(scriptSrcDirective.values().collect(Collectors.toCollection(LinkedHashSet::new))); this.directives.remove(ScriptSrcDirective.class); this.directives.remove(StyleSrcDirective.class); this.directives.put(DefaultSrcDirective.class, defaultSrcDirective); } } }