!ht* #17279 scala side: refactor package structure to new layout

This commit is contained in:
Mathias 2015-04-24 16:33:46 +02:00
parent 29063bce86
commit 10c8cf230e
3 changed files with 18 additions and 9 deletions

View file

@ -121,6 +121,15 @@ package object util {
private[this] val _identityFunc: Any Any = x x
/** Returns a constant identity function to avoid allocating the closure */
private[http] def identityFunc[T]: T T = _identityFunc.asInstanceOf[T T]
private[http] def humanReadableByteCount(bytes: Long, si: Boolean): String = {
val unit = if (si) 1000 else 1024
if (bytes >= unit) {
val exp = (math.log(bytes) / math.log(unit)).toInt
val pre = if (si) "kMGTPE".charAt(exp - 1).toString else "KMGTPE".charAt(exp - 1).toString + 'i'
"%.1f %sB" format (bytes / math.pow(unit, exp), pre)
} else bytes.toString + " B"
}
}
package util {