littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
4.9k stars 771 forks source link

Rename internal functions _raw* -> _*_ #915

Closed geky closed 5 months ago

geky commented 6 months ago

So instead of lfs_file_rawopencfg, it's now lfs_file_opencfg_.

The "raw" prefix is annoying, doesn't really add meaning ("internal" would have been better), and gets in the way of finding the relevant function implementations.

I have been using _s as suffixes for unimportant name collisions in other codebases, and it seems to work well at reducing wasted brain cycles naming things. Adopting it here avoids the need for "raw" prefixes.

It's quite a bit like the use of prime symbols to resolve name collisions in math, e.g. $x' = x + 1$. Which is even supported in Haskell and is quite nice there.

And the main benefit: Now if you search for the public API name, you get the internal function first, which is probably what you care about.

Here is the exact script:

sed -i 's/_raw\([a-z0-9_]*\)\>/_\1_/g' $(git ls-tree -r HEAD --name-only | grep '.*\.c')

This should only affect internal symbols, and have no impact on API compatibility.

This PR will rerun and brought in last on the next minor release, to minimize impact to other PRs.

geky-bot commented 6 months ago
Tests passed ✓, Code: 16820 B (+0.0%), Stack: 1448 B (+0.0%), Structs: 800 B (+0.0%) | | Code | Stack | Structs | | Coverage | |:--|-----:|------:|--------:|:--|---------:| | Default | 16820 B (+0.0%) | 1448 B (+0.0%) | 800 B (+0.0%) | Lines | 2357/2533 lines (+0.0%) | | Readonly | 6130 B (+0.0%) | 448 B (+0.0%) | 800 B (+0.0%) | Branches | 1202/1528 branches (+0.0%) | | Threadsafe | 17688 B (+0.0%) | 1448 B (+0.0%) | 808 B (+0.0%) | | **Benchmarks** | | Multiversion | 16884 B (+0.0%) | 1448 B (+0.0%) | 804 B (+0.0%) | Readed | 29369693876 B (+0.0%) | | Migrate | 18500 B (+0.0%) | 1752 B (+0.0%) | 804 B (+0.0%) | Proged | 1482874766 B (+0.0%) | | Error-asserts | 17480 B (+0.0%) | 1440 B (+0.0%) | 800 B (+0.0%) | Erased | 1568888832 B (+0.0%) |
geky-bot commented 5 months ago
Tests passed ✓, Code: 16972 B (+0.0%), Stack: 1432 B (+0.0%), Structs: 812 B (+0.0%) | | Code | Stack | Structs | | Coverage | |:--|-----:|------:|--------:|:--|---------:| | Default | 16972 B (+0.0%) | 1432 B (+0.0%) | 812 B (+0.0%) | Lines | 2387/2566 lines (-0.0%) | | Readonly | 6186 B (+0.0%) | 448 B (+0.0%) | 812 B (+0.0%) | Branches | 1239/1576 branches (-0.0%) | | Threadsafe | 17836 B (+0.0%) | 1432 B (+0.0%) | 820 B (+0.0%) | | **Benchmarks** | | Multiversion | 17036 B (+0.0%) | 1432 B (+0.0%) | 816 B (+0.0%) | Readed | 29369693876 B (+0.0%) | | Migrate | 18664 B (+0.0%) | 1736 B (+0.0%) | 816 B (+0.0%) | Proged | 1482874766 B (+0.0%) | | Error-asserts | 17660 B (+0.0%) | 1424 B (+0.0%) | 812 B (+0.0%) | Erased | 1568888832 B (+0.0%) |