Skip to content

Conversation

@jacob314
Copy link
Contributor

The idAndType method generates a shorter description with a consistent length
consisting of the runtime type and the a 5 hex character long truncated
version of the hash code.

Feel free to suggest a different method name. I'm not happy about idAndType but I couldn't thinking of anything better and figured you would probably have an opinion on what name would fit well with the rest of Flutter.

…e method.

The idAndType method generates a shorter description with a consistent length
consisting of the runtime type and the a 5 hex character long truncated
version of the hash code.
@jacob314 jacob314 requested a review from Hixie June 21, 2017 00:40
}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

let's put this in a different file, maybe the tree one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

return object.hashCode.toUnsigned(20).toRadixString(16).padLeft(5, '0');
}

/// Returns a summary of [object]'s runtime type and hash code.
Copy link
Contributor

Choose a reason for hiding this comment

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

For arguments we use backticks rather than square brackets because they don't actually hyperlink.

Copy link
Contributor

Choose a reason for hiding this comment

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

(it also causes weird results for methods if you override the method but change the argument name)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}

/// Returns a summary of [object]'s runtime type and hash code.
String idAndType(Object object) => '${object.runtimeType}#${shortHash(object)}';
Copy link
Contributor

Choose a reason for hiding this comment

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

describeIdentity ?

}
}

/// Returns a 5 character long hexadecimal hash code for [object].
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you elaborate on these docs, for example saying that it uses Object.hashCode's twenty least-significant bits?
Also maybe rather than saying it returns a hash code, say that it returns a string based on the hash code? Hash codes are integers and this returns a string. Feel free to phrase this however you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@Hixie
Copy link
Contributor

Hixie commented Jun 21, 2017

LGTM

@jacob314 jacob314 merged commit d46e208 into flutter:master Jun 21, 2017
@Hixie
Copy link
Contributor

Hixie commented Jun 21, 2017

Please make sure you wait for all the checks to pass before landing, even if you only changed comments. We have tests that verify the bodies of comments.

jacob314 added a commit to jacob314/flutter that referenced this pull request Jun 21, 2017
jacob314 added a commit that referenced this pull request Jun 21, 2017
@jacob314
Copy link
Contributor Author

My fault. Reverted for now. I'll re-land in the morning with the case the IntelliJ refactor tool was missing. Odd IntelliJ was showing 0 analyzer issues.

@Hixie
Copy link
Contributor

Hixie commented Jun 21, 2017

Oh wow, I didn't even notice it had actually caused a problem! Just goes to show, I guess!

jacob314 added a commit to jacob314/flutter that referenced this pull request Jun 21, 2017
jacob314 added a commit that referenced this pull request Jun 21, 2017
…eIdentity (#10888)

* Revert "Revert "Change all ocurrences of '$runtimeType#$hashCode' to use the idAndType method. (#10871)" (#10880)"

This reverts commit ceb814a.
gspencergoog pushed a commit to gspencergoog/flutter that referenced this pull request Jul 1, 2017
…e method. (flutter#10871)

* Change all instances of '$runtimeType#$hashCode' to use the describeIdentity method.

The describeIdentity method generates a shorter description with a consistent length
consisting of the runtime type and the a 5 hex character long truncated
version of the hash code.
gspencergoog pushed a commit to gspencergoog/flutter that referenced this pull request Jul 1, 2017
gspencergoog pushed a commit to gspencergoog/flutter that referenced this pull request Jul 1, 2017
…eIdentity (flutter#10888)

* Revert "Revert "Change all ocurrences of '$runtimeType#$hashCode' to use the idAndType method. (flutter#10871)" (flutter#10880)"

This reverts commit ceb814a.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants