Skip to content

Avoid generating empty thread_locals - #315

Open
FranciscoTGouveia wants to merge 2 commits into
Cpp2Rust:masterfrom
FranciscoTGouveia:empty-thread-locals
Open

Avoid generating empty thread_locals#315
FranciscoTGouveia wants to merge 2 commits into
Cpp2Rust:masterfrom
FranciscoTGouveia:empty-thread-locals

Conversation

@FranciscoTGouveia

Copy link
Copy Markdown
Contributor

A new IsConvertableGlobalVarDecl function was introduced to determine whether the global variable declaration would emit any code.
This was needed because empty thread locals were previously being generated (i.e., thread_local!()).

@nunoplopes

Copy link
Copy Markdown
Contributor

This patch seems weird. Isn't the code exactly the same before/after, just less efficient?

@FranciscoTGouveia

Copy link
Copy Markdown
Contributor Author

Before, we would have:

thread_local!(pub static x_0: Value<i32> = <Value<i32>>::default());
thread_local!();

Whereas now, we just have:

thread_local!(pub static x_0: Value<i32> = <Value<i32>>::default());

This has no performance implications, but it avoids generating meaningless statements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants