Skip to content

Small RTT cleanups - #3434

Merged
tlively merged 1 commit into
WebAssembly:masterfrom
tlively:rtt-cleanup
Dec 9, 2020
Merged

tlively merged 1 commit into
WebAssembly:masterfrom
tlively:rtt-cleanup

Conversation

@tlively

@tlively tlively commented Dec 9, 2020

Copy link
Copy Markdown
Member

No description provided.

@tlively
tlively requested a review from kripken December 9, 2020 20:07
Comment thread src/wasm-type.h
NoDepth = -1
};
// An Rtt can have no depth specified
static constexpr uint32_t NoDepth = -1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine either way, but what is the benefit of this approach? The type?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the type explicitly matches its uses, the code is slightly shorter, and it's consistent with other magic values defined in this file (i.e. _last_basic_type).

Comment thread src/wasm-type.h

const struct Rtt& getRtt() const;
// Gets the Rtt for this type, assuming that it is an Rtt type.
Rtt getRtt() const;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit to removing const&? At least the const part seems nice to clarify that this does not return an item to be modified.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no concrete benefit, but since #3428 we have a documented convention of passing Rtts by value. Once you're returning by value, I don't think the const has any effect.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a small benefit to disallowing getRtt().depth = 5 at compile time?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked locally and that is disallowed with or without the const with "error: expression is not assignable."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, thanks for checking!

@tlively
tlively merged commit bdc55d3 into WebAssembly:master Dec 9, 2020
@tlively
tlively deleted the rtt-cleanup branch December 9, 2020 22:28
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