Skip to content

Conversation

@kripken
Copy link
Member

@kripken kripken commented Jan 15, 2019

You had some recent experience with this ;)

@kripken kripken requested a review from tlively January 15, 2019 01:08
@kripken kripken changed the title use moderl T p = v; notation to initialize class fields use modern T p = v; notation to initialize class fields Jan 15, 2019
@kripken kripken changed the title use modern T p = v; notation to initialize class fields Use modern T p = v; notation to initialize class fields Jan 15, 2019
Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

LGTM modulo possible style nit.

int used, available; // used amount, available amount
bool alloced;
int used = 0,
available = init; // used amount, available amount
Copy link
Member

Choose a reason for hiding this comment

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

Is this a standard style we have in the codebase? It looks weird to me to have this split over two lines but only have one int, especially with the comment only on the second line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I don't think we have a style. I don't feel strongly either way. What does LLVM do, btw?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a commit to do it as you suggested.

size_t size, used;
char *buffer = nullptr;
size_t size = 0,
used = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Same here, I would usually default to putting the multiple declarations on the same line, even with definitions.

Copy link
Member

Choose a reason for hiding this comment

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

If we are going to use separate lines (which I think is good when adding initialization), my preference would be just to repeat the type on the second line. That reduces the coupling and makes it easy to move things around if we want.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, agreed, that's what I added now. It's also nicer to avoid T* x, y confusions with pointers.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that's an even better reason actually.


size_t line, col;
size_t line = -1,
col = -1;
Copy link
Member

Choose a reason for hiding this comment

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

Here too.

src/wasm.h Outdated
Name name;
Address initial, max;
Address initial = 0,
max = kMaxSize;
Copy link
Member

Choose a reason for hiding this comment

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

here.

src/wasm.h Outdated
Name name;
Address initial, max; // sizes are in pages
Address initial = 0,
max = kMaxSize; // sizes are in pages
Copy link
Member

Choose a reason for hiding this comment

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

And here. No worries if this is the standard style, of course.

};

IString() : str(nullptr) {}
IString() {}
Copy link
Member

Choose a reason for hiding this comment

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

Not sure it makes a big difference, but I generally see = default used for cases like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, yeah, we should do that too. Adding a commit now.

@kripken kripken merged commit d24427d into master Jan 15, 2019
@kripken kripken deleted the init branch January 15, 2019 21:20
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.

5 participants