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

fix some issues of Array2 #61

Merged
merged 1 commit into from
Jun 22, 2020
Merged

fix some issues of Array2 #61

merged 1 commit into from
Jun 22, 2020

Conversation

qindazhu
Copy link
Collaborator

No description provided.

@@ -112,21 +105,20 @@ struct Array2 {
}

IndexT size1;
IndexT size2; // the number of elements in the array, equal to
Copy link
Collaborator

Choose a reason for hiding this comment

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

The initialization order of data members in the initialization list of the constructors should match the definition order.

Copy link
Collaborator Author

@qindazhu qindazhu Jun 22, 2020

Choose a reason for hiding this comment

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

Actually I prefer to keep the original order (size1, indexes, size2, data) here as it's more readable (indexes is related to size1, and data is related to size2).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Different people have different opinions about what is more readable.

The current approach is more memory-efficient.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will merge and leave it with unresolved. We can update it later if other guys (@danpovey) think we should change the order in the initialization list

@csukuangfj
Copy link
Collaborator

+2

@qindazhu qindazhu merged commit 096fbbe into k2-fsa:master Jun 22, 2020
@qindazhu qindazhu deleted the haowen-algo branch June 22, 2020 04:30
@danpovey
Copy link
Collaborator

danpovey commented Jun 22, 2020 via email

@csukuangfj
Copy link
Collaborator

I agree with haowen, more memory efficient.

I am confused.

@csukuangfj
Copy link
Collaborator

The initialization order of data members in the initialization list of the constructors should match the definition order.

It is a best practice to let the initialization order match the definition order, though the current implementation is fine.

@danpovey
Copy link
Collaborator

danpovey commented Jun 22, 2020 via email

@qindazhu
Copy link
Collaborator Author

There's no any warning in current code.
Anyway, I'll change the initialization order in another PR as I don't want to take more time to argue about what is more readable here.

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.

3 participants