Skip to content

Commit fcdb13e

Browse files
committed
Mark some Ellipse (and related) methods as inline
We're especially interested in marking `Ellipse::radii` inline, motivated by linebender/vello#1180.
1 parent 1f31e44 commit fcdb13e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kurbo/src/ellipse.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ impl Ellipse {
7575
}
7676

7777
/// Create a new `Ellipse` with the provided radii.
78+
#[inline]
7879
#[must_use]
7980
pub fn with_radii(self, new_radii: Vec2) -> Ellipse {
8081
let rotation = self.inner.svd().1;
@@ -87,6 +88,7 @@ impl Ellipse {
8788
///
8889
/// The rotation is clockwise, for a y-down coordinate system. For more
8990
/// on rotation, See [`Affine::rotate`].
91+
#[inline]
9092
#[must_use]
9193
pub fn with_rotation(self, rotation: f64) -> Ellipse {
9294
let scale = self.inner.svd().0;
@@ -118,6 +120,7 @@ impl Ellipse {
118120
///
119121
/// The first number is the horizontal radius and the second is the vertical
120122
/// radius, before rotation.
123+
#[inline]
121124
pub fn radii(&self) -> Vec2 {
122125
self.inner.svd().0
123126
}
@@ -126,13 +129,15 @@ impl Ellipse {
126129
///
127130
/// This allows all possible ellipses to be drawn by always starting with
128131
/// an ellipse with the two radii on the x and y axes.
132+
#[inline]
129133
pub fn rotation(&self) -> f64 {
130134
self.inner.svd().1
131135
}
132136

133137
/// Returns the radii and the rotation of this ellipse.
134138
///
135139
/// Equivalent to `(self.radii(), self.rotation())` but more efficient.
140+
#[inline]
136141
pub fn radii_and_rotation(&self) -> (Vec2, f64) {
137142
self.inner.svd()
138143
}
@@ -181,6 +186,7 @@ impl Sub<Vec2> for Ellipse {
181186

182187
impl Mul<Ellipse> for Affine {
183188
type Output = Ellipse;
189+
#[inline]
184190
fn mul(self, other: Ellipse) -> Self::Output {
185191
Ellipse {
186192
inner: self * other.inner,
@@ -189,6 +195,7 @@ impl Mul<Ellipse> for Affine {
189195
}
190196

191197
impl From<Circle> for Ellipse {
198+
#[inline]
192199
fn from(circle: Circle) -> Self {
193200
Ellipse::new(circle.center, Vec2::splat(circle.radius), 0.0)
194201
}
@@ -248,6 +255,7 @@ impl Shape for Ellipse {
248255
agm_elliptic_perimeter(accuracy, radii)
249256
}
250257

258+
#[inline]
251259
fn winding(&self, pt: Point) -> i32 {
252260
// Strategy here is to apply the inverse map to the point and see if it is in the unit
253261
// circle.

0 commit comments

Comments
 (0)