src/Pure/General/bytes.scala
changeset 80428 5fe811816fa3
parent 80426 7d2922f0ae2b
child 80473 09afc244bb5e
equal deleted inserted replaced
80427:c92356464bb3 80428:5fe811816fa3
   215       buffer_total += 1
   215       buffer_total += 1
   216       buffer_index += 1
   216       buffer_index += 1
   217       buffer_check()
   217       buffer_check()
   218     }
   218     }
   219 
   219 
   220     def += (s: CharSequence): Unit = {
       
   221       val n = s.length
       
   222       if (n > 0) {
       
   223         if (UTF8.relevant(s)) { this += UTF8.bytes(s.toString) }
       
   224         else { for (i <- 0 until n) { this += s.charAt(i).toByte } }
       
   225       }
       
   226     }
       
   227 
       
   228     def += (array: Array[Byte], offset: Int, length: Int): Unit = {
   220     def += (array: Array[Byte], offset: Int, length: Int): Unit = {
   229       if (offset < 0 || length < 0 || offset.toLong + length.toLong > array.length) {
   221       if (offset < 0 || length < 0 || offset.toLong + length.toLong > array.length) {
   230         throw new IndexOutOfBoundsException
   222         throw new IndexOutOfBoundsException
   231       }
   223       }
   232       else {
   224       else {
   241           n -= l
   233           n -= l
   242           buffer_check(request = n)
   234           buffer_check(request = n)
   243         }
   235         }
   244       }
   236       }
   245     }
   237     }
       
   238 
       
   239     def += (s: CharSequence): Unit =
       
   240       if (s.length > 0) { this += UTF8.bytes(s.toString) }
   246 
   241 
   247     def += (array: Array[Byte]): Unit = { this += (array, 0, array.length) }
   242     def += (array: Array[Byte]): Unit = { this += (array, 0, array.length) }
   248 
   243 
   249     def += (a: Subarray): Unit = { this += (a.array, a.offset, a.length) }
   244     def += (a: Subarray): Unit = { this += (a.array, a.offset, a.length) }
   250 
   245