-
Notifications
You must be signed in to change notification settings - Fork 19
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
debox.Map.contains boxes (!) #19
Comments
So, this is actually a specialization failure. If you had a Currently it seems like mixed primitive/Object specializations fail. There was a feature awhile ago ("AnyRef specialization") which was designed to solve this exact problem. But it doesn't seem to be working. I'm looking into this but it's possible that Debox can't fix the problem :/ |
Correct. I think I found the culprit: the specialized annotation (which is performed on the value type) without any arguments involves primitives, excluding AnyRef. See https://github.com/scala/scala/blob/v2.10.4/src/library/scala/specialized.scala#L1 Thus for the pair (Int, AnyRef), the only available variant is (AnyRef, AnyRef). I'm trying to include explicitly AnyRef for the value type and see if it boxes. Will keep you informed. |
No, even when specializing on (Int, AnyRef) for both A and B, it still boxes, even when writing Map[Int, AnyRef] and not a subtype of AnyRef. Removing the specialization on B, the boxing disappears. I will propose a hackish solution in a PR. |
See #20. |
I found a solution for that problem, and ended up implementing a new library for fast data structures: https://github.com/denisrosset/metal . Metal provides data structures that can operate on a mix of primitive/AnyRef types such a However, one drawback of Metal is that it is heavily based towards array-based data structures. For example, linked lists are difficult to implement on its framework. |
debox.Map[Int, AnyRef].contains(key: Int) boxes, I do not know exactly why, but the performance suffers quite a bit:
This is on Scala 2.11.2. I wonder if it is the inner tail recursive method that causes specialization to fail.
The text was updated successfully, but these errors were encountered: