Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 19, 2024
Merged

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

merged 1 commit into from
Jan 19, 2024

Conversation

geky
Copy link
Member

@geky geky commented Dec 21, 2023

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 geky added needs minor version new functionality only allowed in minor versions documentation labels Dec 21, 2023
@geky-bot
Copy link
Collaborator

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 geky added next minor and removed needs minor version new functionality only allowed in minor versions labels Jan 17, 2024
@geky geky added this to the v2.9 milestone Jan 17, 2024
@geky geky changed the base branch from master to devel January 19, 2024 18:20
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')
@geky-bot
Copy link
Collaborator

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%)

@geky geky merged commit a3e1d12 into devel Jan 19, 2024
109 checks passed
@geky geky mentioned this pull request Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants