Tail Recursion Vs. Refactoring
I have this method 

      private def getAddresses(data: List[Int], count: Int, len: Int): Tuple2[List[Address], List[Int]] = {
        if (count == len) {
          (List.empty, List.empty)
        } else {
          val byteAddress = data.takeWhile(_ != 0)
          val newData = data.dropWhile(_ != 0).tail
          val newCount = count + 1
          val newPosition = byteAddress.length + 1
          val destFlag = byteAddress.head
          if (destFlag == SMEAddressFlag) {
            (SMEAddress().fromBytes(byteAddress) :: getAddresses(newData, newCount, len)._1, newPosition :: getAddresses(newData, newCount, len)._2)
          } else {
            (DistributionList().fromBytes(byteAddress) :: getAddresses(newData, newCount, len)._1, newPosition :: getAddresses(newData, newCount, len)._2)
          }
        }
      }

I am tempted to rewrite it thus

      private def getAddresses(data: List[Int], count: Int, len: Int): Tuple2[List[Address], List[Int]] = {
        if (count == len) {
          (List.empty, List.empty)
        } else {
          val byteAddress = data.takeWhile(_ != 0)
          val newData = data.dropWhile(_ != 0).tail
          val newCount = count + 1
          val newPosition = byteAddress.length + 1
          val destFlag = byteAddress.head
          val nextIter = getAddresses(newData, newCount, len)
          if (destFlag == SMEAddressFlag) {
            (SMEAddress().fromBytes(byteAddress) :: nextIter._1, newPosition :: nextIter._2)
          } else {
            (DistributionList().fromBytes(byteAddress) :: nextIter._1, newPosition :: nextIter._2)
          }
        }
      }

My questions are

 1. Is the first one tail recursive?
 2. How does it work? I am calling the method twice in the last line. Does it evaluate to separate method calls what?
 3. Which version is more efficient, or how can I write it more efficiently.

Pardon me if the code **smells** I am new to scala.

Thanks
Tail Recursion Vs. Refactoring
===

I have this method 

      private def getAddresses(data: List[Int], count: Int, len: Int): Tuple2[List[Address], List[Int]] = {
        if (count == len) {
          (List.empty, List.empty)
        } else {
          val byteAddress = data.takeWhile(_ != 0)
          val newData = data.dropWhile(_ != 0).tail
          val newCount = count + 1
          val newPosition = byteAddress.length + 1
          val destFlag = byteAddress.head
          if (destFlag == SMEAddressFlag) {
            (SMEAddress().fromBytes(byteAddress) :: getAddresses(newData, newCount, len)._1, newPosition :: getAddresses(newData, newCount, len)._2)
          } else {
            (DistributionList().fromBytes(byteAddress) :: getAddresses(newData, newCount, len)._1, newPosition :: getAddresses(newData, newCount, len)._2)
          }
        }
      }

I am tempted to rewrite it thus

      private def getAddresses(data: List[Int], count: Int, len: Int): Tuple2[List[Address], List[Int]] = {
        if (count == len) {
          (List.empty, List.empty)
        } else {
          val byteAddress = data.takeWhile(_ != 0)
          val newData = data.dropWhile(_ != 0).tail
          val newCount = count + 1
          val newPosition = byteAddress.length + 1
          val destFlag = byteAddress.head
          val nextIter = getAddresses(newData, newCount, len)
          if (destFlag == SMEAddressFlag) {
            (SMEAddress().fromBytes(byteAddress) :: nextIter._1, newPosition :: nextIter._2)
          } else {
            (DistributionList().fromBytes(byteAddress) :: nextIter._1, newPosition :: nextIter._2)
          }
        }
      }

My questions are

 1. Is the first one tail recursive?
 2. How does it work? I am calling the method twice in the last line. Does it evaluate to separate method calls what?
 3. Which version is more efficient, or how can I write it more efficiently.

Pardon me if the code **smells** I am new to scala.

Thanks