Skip to content

Commit e4df804

Browse files
authored
Set locale when handrolling JSON (#1018)
IDK why, but on my machine, the output of `--time=json` uses decimal commas instead decimal points, so `"lexer": { "my/awesome/file.effekt": 14,15 }, ...` Let's not do that. :) We should also think about using a proper JSON library, esp. if we use it in both documentation (#930) and here, it might just be worth to import [`uJson`](http://www.lihaoyi.com/post/uJsonfastflexibleandintuitiveJSONforScala.html) or something...
1 parent fea824a commit e4df804

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

effekt/shared/src/main/scala/effekt/util/Timer.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,15 @@ trait Timers {
6868
}.mkString("")
6969
}
7070

71-
def timesToJSON(): String = {
71+
private def withENLocale[T](p: => T): T = {
72+
val locale = java.util.Locale.getDefault
73+
java.util.Locale.setDefault(java.util.Locale.US)
74+
val result = p
75+
java.util.Locale.setDefault(locale)
76+
result
77+
}
78+
79+
def timesToJSON(): String = withENLocale {
7280
val spacetab = " ".repeat(4)
7381
val entries = times.map { (name, ts) =>
7482
val subs = ts.map { case Timed(subname, time) =>

0 commit comments

Comments
 (0)