<commit_before>package com.github.mauricio.postgresql.encoders

import org.jboss.netty.buffer.{ChannelBuffers, ChannelBuffer}
import com.github.mauricio.postgresql.messages.StartupMessage
import com.github.mauricio.postgresql.util.Log
import com.github.mauricio.postgresql.{FrontendMessage, ChannelUtils}


/**
 * User: <NAME>
 * Date: 3/3/12
 * Time: 7:35 PM
 */

object StartupMessageEncoder extends Encoder {

  private val log = Log.getByName("StartupMessageEncoder")

  override def encode(message: FrontendMessage): ChannelBuffer = {

    val startup = message.asInstanceOf[StartupMessage]

    val buffer = ChannelBuffers.dynamicBuffer()
    buffer.writeShort( 3 )
    buffer.writeShort( 0 )

    startup.parameters.foreach {
      pair =>
        ChannelUtils.writeCString( pair._1, buffer )
        ChannelUtils.writeCString( pair._2, buffer )
    }

    buffer.writeByte(0)

    buffer
  }

}<commit_msg>removing old and unecessary OutputBuffer<commit_after>package com.github.mauricio.postgresql.encoders

import org.jboss.netty.buffer.{ChannelBuffers, ChannelBuffer}
import com.github.mauricio.postgresql.messages.StartupMessage
import com.github.mauricio.postgresql.util.Log
import com.github.mauricio.postgresql.{FrontendMessage, ChannelUtils}


/**
 * User: <NAME>
 * Date: 3/3/12
 * Time: 7:35 PM
 */

object StartupMessageEncoder extends Encoder {

  private val log = Log.getByName("StartupMessageEncoder")

  override def encode(message: FrontendMessage): ChannelBuffer = {

    val startup = message.asInstanceOf[StartupMessage]

    val buffer = ChannelBuffers.dynamicBuffer()
    buffer.writeInt(0)
    buffer.writeShort( 3 )
    buffer.writeShort( 0 )

    startup.parameters.foreach {
      pair =>
        ChannelUtils.writeCString( pair._1, buffer )
        ChannelUtils.writeCString( pair._2, buffer )
    }

    buffer.writeByte(0)

    val index = buffer.writerIndex()

    buffer.markWriterIndex()
    buffer.writerIndex(0)
    buffer.writeInt(index)
    buffer.resetWriterIndex()

    buffer
  }

}
{'fraction_non_alphanumeric': 0.10300640709709216, 'fraction_numerical': 0.012814194184327254, 'mean_word_length': 3.8798076923076925, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2374345', 'n_tokens_mistral': 660, 'n_tokens_neox': 630, 'n_words': 116}