HHH-13831 Avoid log level check within complex loops
This commit is contained in:
parent
4cd9dd30a0
commit
5f302c57a7
|
@ -204,6 +204,7 @@ class EventListenerGroupImpl<T> implements EventListenerGroup<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
final T[] localListenersRef = this.listeners;
|
final T[] localListenersRef = this.listeners;
|
||||||
|
final boolean debugEnabled = log.isDebugEnabled();
|
||||||
|
|
||||||
for ( DuplicationStrategy strategy : duplicationStrategies ) {
|
for ( DuplicationStrategy strategy : duplicationStrategies ) {
|
||||||
|
|
||||||
|
@ -214,25 +215,33 @@ class EventListenerGroupImpl<T> implements EventListenerGroup<T> {
|
||||||
|
|
||||||
for ( int i = 0; i < localListenersRef.length; i++ ) {
|
for ( int i = 0; i < localListenersRef.length; i++ ) {
|
||||||
final T existingListener = localListenersRef[i];
|
final T existingListener = localListenersRef[i];
|
||||||
|
if ( debugEnabled ) {
|
||||||
log.debugf(
|
log.debugf(
|
||||||
"Checking incoming listener [`%s`] for match against existing listener [`%s`]",
|
"Checking incoming listener [`%s`] for match against existing listener [`%s`]",
|
||||||
listener,
|
listener,
|
||||||
existingListener
|
existingListener
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ( strategy.areMatch( listener, existingListener ) ) {
|
if ( strategy.areMatch( listener, existingListener ) ) {
|
||||||
|
if ( debugEnabled ) {
|
||||||
log.debugf( "Found listener match between `%s` and `%s`", listener, existingListener );
|
log.debugf( "Found listener match between `%s` and `%s`", listener, existingListener );
|
||||||
|
}
|
||||||
|
|
||||||
switch ( strategy.getAction() ) {
|
switch ( strategy.getAction() ) {
|
||||||
case ERROR: {
|
case ERROR: {
|
||||||
throw new EventListenerRegistrationException( "Duplicate event listener found" );
|
throw new EventListenerRegistrationException( "Duplicate event listener found" );
|
||||||
}
|
}
|
||||||
case KEEP_ORIGINAL: {
|
case KEEP_ORIGINAL: {
|
||||||
|
if ( debugEnabled ) {
|
||||||
log.debugf( "Skipping listener registration (%s) : `%s`", strategy.getAction(), listener );
|
log.debugf( "Skipping listener registration (%s) : `%s`", strategy.getAction(), listener );
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case REPLACE_ORIGINAL: {
|
case REPLACE_ORIGINAL: {
|
||||||
|
if ( debugEnabled ) {
|
||||||
log.debugf( "Replacing listener registration (%s) : `%s` -> %s", strategy.getAction(), existingListener, listener );
|
log.debugf( "Replacing listener registration (%s) : `%s` -> %s", strategy.getAction(), existingListener, listener );
|
||||||
|
}
|
||||||
prepareListener( listener );
|
prepareListener( listener );
|
||||||
|
|
||||||
listeners[i] = listener;
|
listeners[i] = listener;
|
||||||
|
|
Loading…
Reference in New Issue