Skip to content

Commit

Permalink
Inline dav1d_ref_is_writable()
Browse files Browse the repository at this point in the history
It's only used in debug mode, so inlining prevents dead code from
being generated in release mode.
  • Loading branch information
gramner-twoorioles authored and Gramner committed May 26, 2023
1 parent 253e466 commit fa8ae57
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,3 @@ void dav1d_ref_dec(Dav1dRef **const pref) {
if (free_ref) free(ref);
}
}

int dav1d_ref_is_writable(Dav1dRef *const ref) {
return atomic_load(&ref->ref_cnt) == 1 && ref->data;
}
5 changes: 4 additions & 1 deletion src/ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ struct Dav1dRef {
Dav1dRef *dav1d_ref_create(size_t size);
Dav1dRef *dav1d_ref_create_using_pool(Dav1dMemPool *pool, size_t size);
void dav1d_ref_dec(Dav1dRef **ref);
int dav1d_ref_is_writable(Dav1dRef *ref);

static inline Dav1dRef *dav1d_ref_init(Dav1dRef *const ref, const void *const ptr,
void (*const free_callback)(const uint8_t *data, void *user_data),
Expand All @@ -67,4 +66,8 @@ static inline void dav1d_ref_inc(Dav1dRef *const ref) {
atomic_fetch_add_explicit(&ref->ref_cnt, 1, memory_order_relaxed);
}

static inline int dav1d_ref_is_writable(Dav1dRef *const ref) {
return atomic_load(&ref->ref_cnt) == 1 && ref->data;
}

#endif /* DAV1D_SRC_REF_H */

0 comments on commit fa8ae57

Please sign in to comment.