Skip to content

Do not use lazy mapValues in TrieNode #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions fastparse/shared/src/test/scala/fastparse/MiscTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,13 @@ object MiscTests extends TestSuite{
Parsed.Failure.formatParser("a", "", 0) == """"a":0:0""",
Parsed.Failure.formatParser("A", "B", 0) == """"A":1:1""")
}
'utils{
'trieNode {
val names = (0 until 1000).map(_.toString.flatMap(_.toString * 5))
val trie = new Utils.TrieNode(names)
for (name <- names)
assert(trie.query(name, 0) != -1)
}
}
}
}
2 changes: 1 addition & 1 deletion utils/shared/src/main/scala/fastparse/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ object Utils {
val (min, max, arr) = {
val children = strings.filter(!_.isEmpty)
.groupBy(_(0))
.mapValues(ss => new TrieNode(ss.map(_.tail)))
.map { case (k,ss) => k -> new TrieNode(ss.map(_.tail)) }
if (children.size == 0) (0.toChar, 0.toChar, new Array[TrieNode](0))
else {
val min = children.keysIterator.min
Expand Down