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

adding extra dominators #19

Merged
merged 2 commits into from
Feb 18, 2018
Merged

Conversation

sendilkumarn
Copy link
Member

fixes #13

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

This looks good @sendilkumarn !

I have a few comments that should be addressed before we merge this, see comments inline below.

Thanks!

@@ -196,6 +196,7 @@ pub fn top(items: &mut ir::Items, opts: &opt::Top) -> Result<Box<traits::Emit>,

struct DominatorTree {
tree: BTreeMap<ir::Id, Vec<ir::Id>>,
dominators: opt::Dominators,
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: let's rename this field to opts

id: ir::Id,
) {
assert_eq!(id == items.meta_root(), depth == 0);

if depth > 0 {
let item = &items[id];
if dominators.max_row != 0 && depth != dominators.max_depth {
Copy link
Member

Choose a reason for hiding this comment

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

Rather than indenting the whole function inside this if, let's:

  • add a new parameter, row: &mut usize
  • add an early return at the start of this function if *row == opts.max_rows || depth > opts.max_depth { return; }
  • whenever we actually add a row to the table, *row += 1;
  • finally, when we first call recursive_add_rows, pass &mut 0 for the rows parameter

These tweaks should make this functionality a little less invasive

opt/opt.rs Outdated

#[structopt(short = "d", default_value = "10")] pub max_depth: usize,

#[structopt(short = "r", default_value = "10")] pub max_row: usize,
Copy link
Member

Choose a reason for hiding this comment

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

NItpick: max_rows instead of `max_row.

Let's also add doc comments to each new field, since this will turn into the CLI help text:

The maximum depth to print the dominators tree.

The maximum number of rows, regardless of depth in the tree, to display.

Let's also make these Option<usize> rather than providing a default value.

if dominators.max_row != 0 && depth != dominators.max_depth {
if depth > 0 {
let item = &items[id];
if let Some(max_rows) = opts.max_rows {
Copy link
Member Author

Choose a reason for hiding this comment

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

Do we have a better syntax here?

This RFC should be handy

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 would be nice, but it is fine as-is, and better than it was before with the indentation of everything. Thanks again!

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

👍 thanks!

@fitzgen fitzgen merged commit 37d3588 into rustwasm:master Feb 18, 2018
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.

Add options for controlling svelte dominators output
2 participants