@PerformanceSensitive("allocation") private static boolean contains(final Marker parent, final Marker... localParents) { // performance tests showed a normal for loop is slightly faster than a for-each loop on some platforms // noinspection ForLoopReplaceableByForEach for (int i = 0, localParentsLength = localParents.length; i < localParentsLength; i++) { final Marker marker = localParents[i]; if (marker == parent) { return true; } } return false; }
/** * Allows message parameters to be iterated over without any allocation * or memory copies. * * @since 2.11 */ @PerformanceSensitive("allocation") public interface ParameterVisitable { /** * Performs the given action for each parameter until all values * have been processed or the action throws an exception. * <p> * The second parameter lets callers pass in a stateful object to be modified with the key-value pairs, * so the TriConsumer implementation itself can be stateless and potentially reusable. * </p> * * @param action The action to be performed for each key-value pair in this collection * @param state the object to be passed as the third parameter to each invocation on the * specified ParameterConsumer. * @param <S> type of the third parameter * @since 2.11 */ <S> void forEachParameter(ParameterConsumer<S> action, S state); }
@PerformanceSensitive("allocation") public interface ReusableMessage extends Message, StringBuilderFormattable {
@PerformanceSensitive public Class<?> getCallerClass(final int depth) { if (depth < 0) { throw new IndexOutOfBoundsException(Integer.toString(depth)); } // note that we need to add 1 to the depth value to compensate for this method, but not for the Method.invoke // since Reflection.getCallerClass ignores the call to Method.invoke() try { return (Class<?>) GET_CALLER_CLASS.invoke(null, depth + 1 + JDK_7u25_OFFSET); } catch (final Exception e) { // theoretically this could happen if the caller class were native code // TODO: return Object.class return null; } }
@PerformanceSensitive("allocation") public class ReusableSimpleMessage implements ReusableMessage, CharSequence, ParameterVisitable, Clearable { private static final long serialVersionUID = -9199974506498249809L;
@PerformanceSensitive("allocation") public class ReusableObjectMessage implements ReusableMessage, ParameterVisitable, Clearable { private static final long serialVersionUID = 6922476812535519960L;
/** * Returns a {@code StringBuilder} containing the text representation of the specified primitive value. * This method will not allocate temporary objects. * * @param value the value whose text representation to return * @return a {@code StringBuilder} containing the text representation of the specified primitive value */ @PerformanceSensitive("allocation") public static StringBuilder box(final long value) { return getSB().append(value); }
/** * Returns a {@code StringBuilder} containing the text representation of the specified primitive value. * This method will not allocate temporary objects. * * @param value the value whose text representation to return * @return a {@code StringBuilder} containing the text representation of the specified primitive value */ @PerformanceSensitive("allocation") public static StringBuilder box(final float value) { return getSB().append(value); }
/** * Returns a {@code StringBuilder} containing the text representation of the specified primitive value. * This method will not allocate temporary objects. * * @param value the value whose text representation to return * @return a {@code StringBuilder} containing the text representation of the specified primitive value */ @PerformanceSensitive("allocation") public static StringBuilder box(final int value) { return getSB().append(value); }
/** * Returns a {@code StringBuilder} containing the text representation of the specified primitive value. * This method will not allocate temporary objects. * * @param value the value whose text representation to return * @return a {@code StringBuilder} containing the text representation of the specified primitive value */ @PerformanceSensitive("allocation") public static StringBuilder box(final char value) { return getSB().append(value); }
/** * Returns a {@code StringBuilder} containing the text representation of the specified primitive value. * This method will not allocate temporary objects. * * @param value the value whose text representation to return * @return a {@code StringBuilder} containing the text representation of the specified primitive value */ @PerformanceSensitive("allocation") public static StringBuilder box(final byte value) { return getSB().append(value); }
/** * Returns a {@code StringBuilder} containing the text representation of the specified primitive value. * This method will not allocate temporary objects. * * @param value the value whose text representation to return * @return a {@code StringBuilder} containing the text representation of the specified primitive value */ @PerformanceSensitive("allocation") public static StringBuilder box(final double value) { return getSB().append(value); }
@PerformanceSensitive public static Class<?> getCallerClass(final String fqcn) { return getCallerClass(fqcn, Strings.EMPTY); }
@PerformanceSensitive public static Class<?> getCallerClass(final Class<?> anchor) { return stackLocator.getCallerClass(anchor); }
@PerformanceSensitive public static Class<?> getCallerClass(final int depth) { return stackLocator.getCallerClass(depth + 1); }
@PerformanceSensitive public static Class<?> getCallerClass(final String fqcn, final String pkg) { return stackLocator.getCallerClass(fqcn, pkg); }
@PerformanceSensitive public static Stack<Class<?>> getCurrentStackTrace() { return stackLocator.getCurrentStackTrace(); }
/** * Returns a {@code StringBuilder} containing the text representation of the specified primitive value. * This method will not allocate temporary objects. * * @param value the value whose text representation to return * @return a {@code StringBuilder} containing the text representation of the specified primitive value */ @PerformanceSensitive("allocation") public static StringBuilder box(final short value) { return getSB().append(value); }
/** * Returns a {@code StringBuilder} containing the text representation of the specified primitive value. * This method will not allocate temporary objects. * * @param value the value whose text representation to return * @return a {@code StringBuilder} containing the text representation of the specified primitive value */ @PerformanceSensitive("allocation") public static StringBuilder box(final boolean value) { return getSB().append(value); }
@PerformanceSensitive("allocation") public final class ReusableMessageFactory implements MessageFactory2, Serializable {