<commit_before>package org.infinispan.protostream.annotations.impl;

import java.lang.reflect.AnnotatedElement;

import org.infinispan.protostream.annotations.ProtoDoc;

/**
 * @author <EMAIL>
 * @since 3.0
 */
final class DocumentationExtractor {

   /**
    * Collect and concatenate the description text from the ProtoDoc.value of the given elements.
    */
   public static String getDocumentation(AnnotatedElement... elements) {
      StringBuilder sb = null;

      for (AnnotatedElement element : elements) {
         for (ProtoDoc docAnnotation : element.getAnnotationsByType(ProtoDoc.class)) {
            if (docAnnotation != null && !docAnnotation.value().isEmpty()) {
               if (sb == null) {
                  sb = new StringBuilder();
               } else {
                  sb.append('\n');
               }
               sb.append(docAnnotation.value());
            }
         }
      }

      return sb == null ? null : sb.toString();
   }
}<commit_msg>Refactor DocumentationExtractor to avoid creation of vararg arrays at invocation<commit_after>package org.infinispan.protostream.annotations.impl;

import java.lang.reflect.AnnotatedElement;

import org.infinispan.protostream.annotations.ProtoDoc;

/**
 * @author <EMAIL>
 * @since 3.0
 */
final class DocumentationExtractor {

   /**
    * Collect and concatenate the description text from the {@code @ProtoDoc.value} of the given elements.
    */
   public static String getDocumentation(AnnotatedElement element1, AnnotatedElement element2) {
      String doc1 = getDocumentation(element1);
      String doc2 = getDocumentation(element2);

      if (doc1 == null) {
         return doc2;
      }
      if (doc2 == null) {
         return doc1;
      }
      return doc1 + '\n' + doc2;
   }

   /**
    * Collect and concatenate the description text from the {@code @ProtoDoc.value} of the given element.
    */
   public static String getDocumentation(AnnotatedElement element) {
      StringBuilder sb = null;

      for (ProtoDoc docAnnotation : element.getAnnotationsByType(ProtoDoc.class)) {
         if (!docAnnotation.value().isEmpty()) {
            if (sb == null) {
               sb = new StringBuilder();
            } else {
               sb.append('\n');
            }
            sb.append(docAnnotation.value());
         }
      }

      return sb == null ? null : sb.toString();
   }
}
{'fraction_non_alphanumeric': 0.10845896147403684, 'fraction_numerical': 0.006700167504187605, 'mean_word_length': 2.360056258790436, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4560036', 'n_tokens_mistral': 664, 'n_tokens_neox': 646, 'n_words': 165}