# gpui: Optimize coalesce float sign checking \(\#28072\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/24d4f8ca1808138738b84bbf7cb6d006796ffa1a)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 24d4f8ca1808138738b84bbf7cb6d006796ffa1a

Requested commit: 24d4f8ca1808138738b84bbf7cb6d006796ffa1a

Commit: 24d4f8ca1808138738b84bbf7cb6d006796ffa1a

Tree: aed746033cd15540a494ebf7f62d1f21d8899e87

Author: tidely

Committer: GitHub

## Message

````
gpui: Optimize coalesce float sign checking (#28072)

Optimize away a multiplication during in the `coalesce` function. Our
goal is to check whether the sign of two floats is the same.

Instead of multiplying each `.signum()` and checking that the result is
positive, we can simply check that the signum's are the same. This
removes a float multiplication.

```rust
a.signum() * b.signum() >= 0.0
```

turns into

```rust
a.signum() == b.signum()
```



Release Notes:

- Fix documentation for `Pixels::signum`
````

## Parents

- [804066a0471b47219ed69eacf7f6d85571f839a1](https://git.cafe/gitcafe/zed/commit/804066a0471b47219ed69eacf7f6d85571f839a1?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/24d4f8ca1808138738b84bbf7cb6d006796ffa1a?format=markdown)
