From c6f73bb892a200dec4599d982538230ee70bc0cf Mon Sep 17 00:00:00 2001
From: Ezo <ezo.dev@gmail.com>
Date: Tue, 19 Nov 2013 22:57:40 +0000
Subject: [PATCH] Changed unchecked dynamic casts to reinterpret casts. Dynamic
casts is useless if there is no checking. It's slower than reinterpret casts
too.
---
src/apps/debugger/arch/x86/ArchitectureX86.cpp | 2 +-
src/apps/debugger/model/Type.cpp | 2 +-
src/apps/debugger/user_interface/gui/util/SettingsMenu.cpp | 2 +-
src/apps/debugger/value/value_nodes/ArrayValueNode.cpp | 2 +-
src/apps/debugger/value/value_nodes/BMessageValueNode.cpp | 6 +++---
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/apps/debugger/arch/x86/ArchitectureX86.cpp b/src/apps/debugger/arch/x86/ArchitectureX86.cpp
index b0bec17..15c4ffb 100644
a
|
b
|
ArchitectureX86::UpdateStackFrameCpuState(const StackFrame* frame,
|
415 | 415 | { |
416 | 416 | // This is not a top frame, so we want to offset eip to the previous |
417 | 417 | // (calling) instruction. |
418 | | CpuStateX86* cpuState = dynamic_cast<CpuStateX86*>(previousCpuState); |
| 418 | CpuStateX86* cpuState = reinterpret_cast<CpuStateX86*>(previousCpuState); |
419 | 419 | |
420 | 420 | // get eip |
421 | 421 | uint32 eip = cpuState->IntRegisterValue(X86_REGISTER_EIP); |
diff --git a/src/apps/debugger/model/Type.cpp b/src/apps/debugger/model/Type.cpp
index 318abf2..34d4f9b 100644
a
|
b
|
ArrayDimension::CountElements() const
|
48 | 48 | return dynamic_cast<EnumerationType*>(type)->CountValues(); |
49 | 49 | |
50 | 50 | if (type->Kind() == TYPE_SUBRANGE) { |
51 | | SubrangeType* subrangeType = dynamic_cast<SubrangeType*>(type); |
| 51 | SubrangeType* subrangeType = reinterpret_cast<SubrangeType*>(type); |
52 | 52 | BVariant lower = subrangeType->LowerBound(); |
53 | 53 | BVariant upper = subrangeType->UpperBound(); |
54 | 54 | bool isSigned; |
diff --git a/src/apps/debugger/user_interface/gui/util/SettingsMenu.cpp b/src/apps/debugger/user_interface/gui/util/SettingsMenu.cpp
index 6165eef..1706c7a 100644
a
|
b
|
public:
|
175 | 175 | Settings* settings) |
176 | 176 | { |
177 | 177 | SettingsOption* selectedOption = settings->OptionValue( |
178 | | dynamic_cast<OptionsSetting*>(GetSetting())); |
| 178 | reinterpret_cast<OptionsSetting*>(GetSetting())); |
179 | 179 | |
180 | 180 | for (int32 i = 0; BMenuItem* item = Submenu()->ItemAt(i); i++) { |
181 | 181 | OptionMenuItem* optionItem = dynamic_cast<OptionMenuItem*>(item); |
diff --git a/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp b/src/apps/debugger/value/value_nodes/ArrayValueNode.cpp
index bc05323..a809556 100644
a
|
b
|
ArrayValueNodeChild::ResolveLocation(ValueLoader* valueLoader,
|
313 | 313 | for (int32 i = dimensionCount - 1; i >= 0; i--) { |
314 | 314 | indexPath.SetIndexAt(i, child->ElementIndex()); |
315 | 315 | |
316 | | child = dynamic_cast<AbstractArrayValueNodeChild*>( |
| 316 | child = reinterpret_cast<AbstractArrayValueNodeChild*>( |
317 | 317 | child->ArrayParent()->NodeChild()); |
318 | 318 | } |
319 | 319 | |
diff --git a/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp b/src/apps/debugger/value/value_nodes/BMessageValueNode.cpp
index 0da34fe..94f0563 100644
a
|
b
|
public:
|
69 | 69 | { |
70 | 70 | ValueLocation* parentLocation = fParent->Location(); |
71 | 71 | ValueLocation* location; |
72 | | CompoundType* type = dynamic_cast<CompoundType*>(fParent->GetType()); |
| 72 | CompoundType* type = reinterpret_cast<CompoundType*>(fParent->GetType()); |
73 | 73 | status_t error = B_OK; |
74 | 74 | if (fParent->fIsFlatMessage) { |
75 | 75 | location = new ValueLocation(); |
… |
… |
BMessageValueNode::ResolvedLocationAndValue(ValueLoader* valueLoader,
|
174 | 174 | BVariant fieldAddress; |
175 | 175 | BVariant what; |
176 | 176 | |
177 | | CompoundType* baseType = dynamic_cast<CompoundType*>(fType); |
| 177 | CompoundType* baseType = reinterpret_cast<CompoundType*>(fType); |
178 | 178 | |
179 | 179 | if (fIsFlatMessage) { |
180 | 180 | headerAddress.SetTo(location->PieceAt(0).address); |
… |
… |
status_t
|
333 | 333 | BMessageValueNode::CreateChildren() |
334 | 334 | { |
335 | 335 | DataMember* member = NULL; |
336 | | CompoundType* messageType = dynamic_cast<CompoundType*>(fType); |
| 336 | CompoundType* messageType = reinterpret_cast<CompoundType*>(fType); |
337 | 337 | for (int32 i = 0; i < messageType->CountDataMembers(); i++) { |
338 | 338 | member = messageType->DataMemberAt(i); |
339 | 339 | if (strcmp(member->Name(), "what") == 0) { |