-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
Right now the implementation of Eq
and Neq
methods looks like this:
// Eq is "==" operation.
func (c Complex64) Eq(x Complex64) bool {
return c.r == x.r && c.i == x.i
}
// Neq is "!=" operation.
func (c Complex64) Neq(x Complex64) bool {
return c.r != x.r || c.i != x.i
}
I'm just wondering, have you considered the following alternative implementation?
// Eq is "==" operation.
func (c Complex64) Eq(x Complex64) bool {
return c == x
}
// Neq is "!=" operation.
func (c Complex64) Neq(x Complex64) bool {
return c != x
}
Since the struct contains just two float32
fields, the behavior would be identical. But it's shorter, and perhaps simpler/more readable? Of course, that's debatable.
I would expect it to generate identical assembly, but case it's not, would it be faster or slower?
It's just a thought that came to mind when seeing that code, so I wanted to share it.
Metadata
Metadata
Assignees
Labels
No labels