!ht* #17279 scala side: refactor package structure to new layout
This commit is contained in:
parent
29063bce86
commit
10c8cf230e
3 changed files with 18 additions and 9 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue