Adopted ctz skip-list structure earlier than expected
The primary data structure backing the little fs was planned to be a little ctz based skip-list for O(logn) lookup and O(1) append. Was initially planning to start with a simple linked list of index blocks, but was having trouble implementing the free-list on top of the structure. Went ahead and adopted the skip-list structure since it may have actually been easier.
This commit is contained in:
@@ -34,4 +34,12 @@ static inline lfs_word_t lfs_min(lfs_word_t a, lfs_word_t b) {
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
static inline lfs_word_t lfs_ctz(lfs_word_t a) {
|
||||
return __builtin_ctz(a);
|
||||
}
|
||||
|
||||
static inline lfs_word_t lfs_npw2(lfs_word_t a) {
|
||||
return 32 - __builtin_clz(a-1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user