Skip to content

Commit 473e486

Browse files
authored
chore: #[inline] fns vortex-array (#4477)
Annotates small functions in vortex-array with `#[inline]` that could benefit from cross crate inlining. Signed-off-by: Alexander Droste <[email protected]>
1 parent 27c7838 commit 473e486

File tree

6 files changed

+60
-0
lines changed

6 files changed

+60
-0
lines changed

vortex-array/src/array/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,62 +158,77 @@ pub trait Array: 'static + private::Sealed + Send + Sync + Debug + ArrayVisitor
158158
}
159159

160160
impl Array for Arc<dyn Array> {
161+
#[inline]
161162
fn as_any(&self) -> &dyn Any {
162163
self.as_ref().as_any()
163164
}
164165

166+
#[inline]
165167
fn to_array(&self) -> ArrayRef {
166168
self.clone()
167169
}
168170

171+
#[inline]
169172
fn len(&self) -> usize {
170173
self.as_ref().len()
171174
}
172175

176+
#[inline]
173177
fn dtype(&self) -> &DType {
174178
self.as_ref().dtype()
175179
}
176180

181+
#[inline]
177182
fn encoding(&self) -> EncodingRef {
178183
self.as_ref().encoding()
179184
}
180185

186+
#[inline]
181187
fn encoding_id(&self) -> EncodingId {
182188
self.as_ref().encoding_id()
183189
}
184190

191+
#[inline]
185192
fn slice(&self, range: Range<usize>) -> ArrayRef {
186193
self.as_ref().slice(range)
187194
}
188195

196+
#[inline]
189197
fn scalar_at(&self, index: usize) -> Scalar {
190198
self.as_ref().scalar_at(index)
191199
}
192200

201+
#[inline]
193202
fn is_valid(&self, index: usize) -> bool {
194203
self.as_ref().is_valid(index)
195204
}
196205

206+
#[inline]
197207
fn is_invalid(&self, index: usize) -> bool {
198208
self.as_ref().is_invalid(index)
199209
}
200210

211+
#[inline]
201212
fn all_valid(&self) -> bool {
202213
self.as_ref().all_valid()
203214
}
204215

216+
#[inline]
205217
fn all_invalid(&self) -> bool {
206218
self.as_ref().all_invalid()
207219
}
208220

221+
#[inline]
209222
fn valid_count(&self) -> usize {
210223
self.as_ref().valid_count()
211224
}
212225

226+
#[inline]
213227
fn invalid_count(&self) -> usize {
214228
self.as_ref().invalid_count()
215229
}
216230

231+
#[inline]
217232
fn validity_mask(&self) -> Mask {
218233
self.as_ref().validity_mask()
219234
}

vortex-array/src/iter.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub trait ArrayIterator: Iterator<Item = VortexResult<ArrayRef>> {
2121
}
2222

2323
impl ArrayIterator for Box<dyn ArrayIterator + Send> {
24+
#[inline]
2425
fn dtype(&self) -> &DType {
2526
self.as_ref().dtype()
2627
}
@@ -32,6 +33,7 @@ pub struct ArrayIteratorAdapter<I> {
3233
}
3334

3435
impl<I> ArrayIteratorAdapter<I> {
36+
#[inline]
3537
pub fn new(dtype: DType, inner: I) -> Self {
3638
Self { dtype, inner }
3739
}
@@ -43,6 +45,7 @@ where
4345
{
4446
type Item = VortexResult<ArrayRef>;
4547

48+
#[inline]
4649
fn next(&mut self) -> Option<Self::Item> {
4750
self.inner.next()
4851
}
@@ -52,6 +55,7 @@ impl<I> ArrayIterator for ArrayIteratorAdapter<I>
5255
where
5356
I: Iterator<Item = VortexResult<ArrayRef>>,
5457
{
58+
#[inline]
5559
fn dtype(&self) -> &DType {
5660
&self.dtype
5761
}
@@ -107,6 +111,7 @@ enum ArrayChunkIterator {
107111
impl Iterator for ArrayChunkIterator {
108112
type Item = VortexResult<ArrayRef>;
109113

114+
#[inline]
110115
fn next(&mut self) -> Option<Self::Item> {
111116
match self {
112117
ArrayChunkIterator::Single(array) => array.take().map(Ok),

vortex-array/src/metadata.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub struct ProstMetadata<M>(pub M);
7474
impl<M> Deref for ProstMetadata<M> {
7575
type Target = M;
7676

77+
#[inline]
7778
fn deref(&self) -> &Self::Target {
7879
&self.0
7980
}

vortex-array/src/partial_ord.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ where
1818
}
1919
}
2020

21+
#[inline]
2122
pub fn partial_min<T: PartialMin>(a: T, b: T) -> Option<T> {
2223
a.partial_min(b)
2324
}
@@ -41,6 +42,7 @@ where
4142

4243
impl<T: PartialOrd> PartialMax for T {}
4344

45+
#[inline]
4446
pub fn partial_max<T: PartialMax>(a: T, b: T) -> Option<T> {
4547
a.partial_max(b)
4648
}

vortex-array/src/patches.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub struct PatchesMetadata {
3737
}
3838

3939
impl PatchesMetadata {
40+
#[inline]
4041
pub fn new(len: usize, offset: usize, indices_ptype: PType) -> Self {
4142
Self {
4243
len: len as u64,
@@ -134,46 +135,57 @@ impl Patches {
134135
}
135136
}
136137

138+
#[inline]
137139
pub fn array_len(&self) -> usize {
138140
self.array_len
139141
}
140142

143+
#[inline]
141144
pub fn num_patches(&self) -> usize {
142145
self.indices.len()
143146
}
144147

148+
#[inline]
145149
pub fn dtype(&self) -> &DType {
146150
self.values.dtype()
147151
}
148152

153+
#[inline]
149154
pub fn indices(&self) -> &ArrayRef {
150155
&self.indices
151156
}
152157

158+
#[inline]
153159
pub fn into_indices(self) -> ArrayRef {
154160
self.indices
155161
}
156162

163+
#[inline]
157164
pub fn indices_mut(&mut self) -> &mut ArrayRef {
158165
&mut self.indices
159166
}
160167

168+
#[inline]
161169
pub fn values(&self) -> &ArrayRef {
162170
&self.values
163171
}
164172

173+
#[inline]
165174
pub fn into_values(self) -> ArrayRef {
166175
self.values
167176
}
168177

178+
#[inline]
169179
pub fn values_mut(&mut self) -> &mut ArrayRef {
170180
&mut self.values
171181
}
172182

183+
#[inline]
173184
pub fn offset(&self) -> usize {
174185
self.offset
175186
}
176187

188+
#[inline]
177189
pub fn indices_ptype(&self) -> PType {
178190
PType::try_from(self.indices.dtype()).vortex_expect("primitive indices")
179191
}

0 commit comments

Comments
 (0)