-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Override size in Chain instance #2425
Conversation
This should be a slight optimization.
@@ -538,6 +538,7 @@ private[data] sealed abstract class ChainInstances extends ChainInstances1 { | |||
override def exists[A](fa: Chain[A])(p: A => Boolean): Boolean = fa.exists(p) | |||
override def forall[A](fa: Chain[A])(p: A => Boolean): Boolean = fa.forall(p) | |||
override def find[A](fa: Chain[A])(f: A => Boolean): Option[A] = fa.find(f) | |||
override def size[A](fa: Chain[A]): Long = fa.length.toLong |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fa.length
already returns Long
, so no need for the call to toLong
:)
I'm pretty sure that it returned a long when I looked. Either i was looking
at outdated code or I'm seeing things :)
It might be a while before I'm at a computer to fix this.
…On Sun, Aug 19, 2018, 7:55 AM Luka Jacobowitz ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In core/src/main/scala/cats/data/Chain.scala
<#2425 (comment)>:
> @@ -538,6 +538,7 @@ private[data] sealed abstract class ChainInstances extends ChainInstances1 {
override def exists[A](fa: Chain[A])(p: A => Boolean): Boolean = fa.exists(p)
override def forall[A](fa: Chain[A])(p: A => Boolean): Boolean = fa.forall(p)
override def find[A](fa: Chain[A])(f: A => Boolean): Option[A] = fa.find(f)
+ override def size[A](fa: Chain[A]): Long = fa.length.toLong
fa.length already returns Long, so no need for the call to toLong :)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2425 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA7sCWuuEghj3zcQHsxN4ubkG-7d-Ab-ks5uSaapgaJpZM4WDCy->
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add benchmarks to provide evidence? @LukaJCB already started us out strong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I guess here we are just delegating to the type specific version so never mind.
Codecov Report
@@ Coverage Diff @@
## master #2425 +/- ##
==========================================
- Coverage 95.22% 95.21% -0.02%
==========================================
Files 351 351
Lines 6368 6369 +1
Branches 279 281 +2
==========================================
Hits 6064 6064
- Misses 304 305 +1
Continue to review full report at Codecov.
|
* Override size in Chain instance This should be a slight optimization. * Update Chain.scala
This should be a slight optimization.