Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(642)

Unified Diff: runtime/vm/object.cc

Issue 10713008: Introduce a VM type cast to avoid repeating a type test and spare a handle. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 9203)
+++ runtime/vm/object.cc (working copy)
@@ -2442,9 +2442,7 @@
// a class B<T> will never require a run time bounds check, even it T is
// uninstantiated at compile time.
if (IsTypeParameter()) {
- // TODO(regis): Introduce and use TypeParameter::Cast().
- const TypeParameter* type_param =
- reinterpret_cast<const TypeParameter*>(this);
+ const TypeParameter* type_param = TypeParameter::Cast(*this);
Ivan Posva 2012/06/28 16:35:09 I am wondering if we will need a static const ob
regis 2012/06/28 18:44:51 Isn't it exactly what we have? That is, before I c
if (other.IsTypeParameter()) {
const TypeParameter* other_type_param =
reinterpret_cast<const TypeParameter*>(&other);
@@ -3313,8 +3311,7 @@
if (!type.IsTypeParameter()) {
return false;
}
- // TODO(regis): Introduce and use TypeParameter::Cast().
- TypeParameter* type_param = reinterpret_cast<TypeParameter*>(&type);
+ const TypeParameter* type_param = TypeParameter::Cast(type);
if ((type_param->index() != i)) {
siva 2012/06/28 17:02:51 For example this would be const TypeParameter& typ
regis 2012/06/28 18:44:51 Done.
return false;
}
@@ -7216,9 +7213,7 @@
if (other_instantiator.IsNull()) {
return true; // Other type is uninstantiated, i.e. Dynamic.
}
- // TODO(regis): Introduce and use TypeParameter::Cast().
- const TypeParameter* other_type_param =
- reinterpret_cast<const TypeParameter*>(&other);
+ const TypeParameter* other_type_param = TypeParameter::Cast(other);
const AbstractType& instantiated_other = AbstractType::Handle(
other_instantiator.TypeAt(other_type_param->index()));
ASSERT(instantiated_other.IsInstantiated());
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698