<commit_before>@(diff: playRepository.FileDiff, comments: java.util.List[_ <: CodeComment], projectB: Project, projectA: Project)

@import playRepository.DiffLineType
@import playRepository.DiffLine
@import playRepository.FileDiff
@import org.eclipse.jgit.diff.DiffEntry
@import org.eclipse.jgit.diff.RawText
@import utils.TemplateHelper.DiffRenderer._
@import utils.TemplateHelper._
@import scala.collection.immutable.Map
@import scala.collection.immutable.List
@import scala.collection.JavaConversions._

@**
 * 변경 내용(Diff) 표시
 *
 * @param diff
 * @param comments
**@
@renderDiffLines(diff: playRepository.FileDiff, comments: Map[String, List[_ <: CodeComment]]) = {
  @if(diff.getHunks.size > 0){
    @for(hunk <- diff.getHunks) {
      <tr class="range"><td>...</td><td>...</td><td>@@@@ -@(hunk.beginA + 1),@(hunk.endA - hunk.beginA) +@(hunk.beginB + 1),@(hunk.endB - hunk.beginB) @@@@</td></tr>
      @Html(renderLines(hunk.lines.toList, comments))
    }
  } else {
    <tr><td colspan=3>@Messages("code.noChanges")</td></tr>
  }
}

@**
 * 파일 내용 표시
 *
 * @param klass
 * @param path
 * @param rawText
 * @param kind
 * @param prefix
 * @param comments
**@
@renderRawFile(klass: String, path: String, rawText: RawText, side: CodeComment.Side, prefix: String, comments: Map[String, List[_ <: CodeComment]]) = {
    @for(i <- 0 until rawText.size) {
        @partial_diff_line(klass, prefix, i + 1, null, i + 1, rawText.getString(i))
        @partial_diff_comment_on_line(commentsOrEmpty(comments, commentKey(path, side, i + 1)))
    }
}

@**
 * 추가된 라인 표시
 *
 * @param rawText
 * @param path
 * @param comments
 * @param isBinaryOverwritten 기존 데이터가 바이너리인 경우 true
**@
@renderAddedLines(rawText: RawText, path: String, comments:Map[String, List[_ <: CodeComment]], isBinaryOverwritten: Boolean = false) = {
  <tr class="range"><td>...</td><td>...</td><td>@@@@ -0,0 +1,@rawText.size @@@@</td></tr>
  @if(isBinaryOverwritten ){
      @renderCodeIsBinary("remove", "-")
  }<commit_msg>PullRequest: Make renderRawFile 40% faster by StringBuilder<commit_after>@(diff: playRepository.FileDiff, comments: java.util.List[_ <: CodeComment], projectB: Project, projectA: Project)

@import playRepository.DiffLineType
@import playRepository.DiffLine
@import playRepository.FileDiff
@import org.eclipse.jgit.diff.DiffEntry
@import org.eclipse.jgit.diff.RawText
@import utils.TemplateHelper.DiffRenderer._
@import utils.TemplateHelper._
@import scala.collection.immutable.Map
@import scala.collection.immutable.List
@import scala.collection.JavaConversions._
@import org.apache.commons.lang.StringEscapeUtils.escapeHtml;

@**
 * 변경 내용(Diff) 표시
 *
 * @param diff
 * @param comments
**@
@renderDiffLines(diff: playRepository.FileDiff, comments: Map[String, List[_ <: CodeComment]]) = {
  @if(diff.getHunks.size > 0){
    @for(hunk <- diff.getHunks) {
      <tr class="range"><td>...</td><td>...</td><td>@@@@ -@(hunk.beginA + 1),@(hunk.endA - hunk.beginA) +@(hunk.beginB + 1),@(hunk.endB - hunk.beginB) @@@@</td></tr>
      @Html(renderLines(hunk.lines.toList, comments))
    }
  } else {
    <tr><td colspan=3>@Messages("code.noChanges")</td></tr>
  }
}

@**
 * 파일 내용 표시
 *
 * 성능 문제를 해결하기 위해 StringBuilder를 사용했다.
 *
 * 주의: StringBuilder는 thread-safe 하지 않다.
 *
 * @param klass
 * @param path
 * @param rawText
 * @param kind
 * @param prefix
 * @param comments
**@
@renderRawFile(klass: String, path: String, rawText: RawText, side: CodeComment.Side, prefix: String, comments: Map[String, List[_ <: CodeComment]]) = {
    @defining(new StringBuilder) { builder =>
        @for(i <- 0 until rawText.size) @{
            builder.append("<tr class='")
            builder.append(klass)
            builder.append("' data-line='")
            builder.append(i + 1)
            builder.append("' data-type='")
            builder.append(klass)
            builder.append("'><td class='linenum'><i class='icon-comment'></i></td><td class='linenum'>")
            builder.append(i + 1)
            builder.append("</td><td class='code'><span>")
            builder.append(prefix)
            builder.append("</span>")
            builder.append(escapeHtml(rawText.getString(i)))
            builder.append(partial_diff_comment_on_line(commentsOrEmpty(comments, commentKey(path, side, i + 1))).toString.trim)
        }
        @Html(builder.toString)
    }
}

@**
 * 추가된 라인 표시
 *
 * @param rawText
 * @param path
 * @param comments
 * @param isBinaryOverwritten 기존 데이터가 바이너리인 경우 true
**@
@renderAddedLines(rawText: RawText, path: String, comments:Map[String, List[_ <: CodeComment]], isBinaryOverwritten: Boolean = false) = {
  <tr class="range"><td>...</td><td>...</td><td>@@@@ -0,0 +1,@rawText.size @@@@</td></tr>
  @if(isBinaryOverwritten ){
      @renderCodeIsBinary("remove", "-")
  }
{'fraction_non_alphanumeric': 0.17775445960125918, 'fraction_numerical': 0.005036726128016789, 'mean_word_length': 3.9801462904911182, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 56, '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': '5547564', 'n_tokens_mistral': 1704, 'n_tokens_neox': 1775, 'n_words': 314}