<commit_before>package net.fehmicansaglam.tepkin.api

import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
import net.fehmicansaglam.bson.element.BsonElement
import net.fehmicansaglam.bson.{BsonDocument, BsonValue}

import scala.collection.mutable.ArrayBuffer

class BsonDocumentBuilder {

  private var elements = ArrayBuffer.empty[BsonElement]

  def add(name: String, value: BsonValue): BsonDocumentBuilder = {
    elements :+= (name := value)
    this
  }

  def addString(name: String, value: String): BsonDocumentBuilder = {
    elements :+= (name := value)
    this
  }

  def addInt(name: String, value: Int): BsonDocumentBuilder = {
    elements :+= (name := value)
    this
  }

  def addLong(name: String, value: Long): BsonDocumentBuilder = {
    elements :+= (name := value)
    this
  }

  def addDouble(name: String, value: Double): BsonDocumentBuilder = {
    elements :+= (name := value)
    this
  }

  def addBoolean(name: String, value: Boolean): BsonDocumentBuilder = {
    elements :+= (name := value)
    this
  }

  def build(): BsonDocument = {
    BsonDocument(elements)
  }
}

object BsonDocumentBuilder {
  def create: BsonDocumentBuilder = new BsonDocumentBuilder
}<commit_msg>Don't create copy of the elements array in BsonDocumentBuilder<commit_after>package net.fehmicansaglam.tepkin.api

import net.fehmicansaglam.bson.BsonDsl._
import net.fehmicansaglam.bson.Implicits._
import net.fehmicansaglam.bson.element.BsonElement
import net.fehmicansaglam.bson.{BsonDocument, BsonValue}

import scala.collection.mutable.ArrayBuffer

class BsonDocumentBuilder {

  private val elements = ArrayBuffer.empty[BsonElement]

  def add(name: String, value: BsonValue): BsonDocumentBuilder = {
    elements += (name := value)
    this
  }

  def addString(name: String, value: String): BsonDocumentBuilder = {
    elements += (name := value)
    this
  }

  def addInt(name: String, value: Int): BsonDocumentBuilder = {
    elements += (name := value)
    this
  }

  def addLong(name: String, value: Long): BsonDocumentBuilder = {
    elements += (name := value)
    this
  }

  def addDouble(name: String, value: Double): BsonDocumentBuilder = {
    elements += (name := value)
    this
  }

  def addBoolean(name: String, value: Boolean): BsonDocumentBuilder = {
    elements += (name := value)
    this
  }

  def build(): BsonDocument = {
    BsonDocument(elements)
  }
}

object BsonDocumentBuilder {
  def create: BsonDocumentBuilder = new BsonDocumentBuilder
}
{'fraction_non_alphanumeric': 0.11005164878823996, 'fraction_numerical': 0.0, 'mean_word_length': 4.025948103792415, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2565422', 'n_tokens_mistral': 820, 'n_tokens_neox': 813, 'n_words': 188}