diff options
author | halyavin <halyavin@chromium.org> | 2015-03-12 02:14:39 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-12 09:15:23 +0000 |
commit | 6ee225f759b8a6ca8953a7d695a135df9053188b (patch) | |
tree | 2e0330d7fc231f6df07860f25f4c6c10b3a6bebb /courgette | |
parent | d1677fd03abc26d747174dafb7124a42d505ae2e (diff) | |
download | chromium_src-6ee225f759b8a6ca8953a7d695a135df9053188b.zip chromium_src-6ee225f759b8a6ca8953a7d695a135df9053188b.tar.gz chromium_src-6ee225f759b8a6ca8953a7d695a135df9053188b.tar.bz2 |
Make ParseNonSectionFileRegion a bit simplier and faster.
TEST=courgette_unittests
BUG= none
R=wfh@chromium.org
Review URL: https://codereview.chromium.org/998443002
Cr-Commit-Position: refs/heads/master@{#320252}
Diffstat (limited to 'courgette')
-rw-r--r-- | courgette/disassembler_win32_x64.cc | 12 | ||||
-rw-r--r-- | courgette/disassembler_win32_x86.cc | 12 |
2 files changed, 8 insertions, 16 deletions
diff --git a/courgette/disassembler_win32_x64.cc b/courgette/disassembler_win32_x64.cc index 04356d7..626bd35 100644 --- a/courgette/disassembler_win32_x64.cc +++ b/courgette/disassembler_win32_x64.cc @@ -514,15 +514,11 @@ CheckBool DisassemblerWin32X64::ParseNonSectionFileRegion( if (incomplete_disassembly_) return true; - const uint8* start = OffsetToPointer(start_file_offset); - const uint8* end = OffsetToPointer(end_file_offset); - - const uint8* p = start; - - while (p < end) { - if (!program->EmitByteInstruction(*p)) + if (end_file_offset > start_file_offset) { + if (!program->EmitBytesInstruction(OffsetToPointer(start_file_offset), + end_file_offset - start_file_offset)) { return false; - ++p; + } } return true; diff --git a/courgette/disassembler_win32_x86.cc b/courgette/disassembler_win32_x86.cc index eeb17ec..bb300d9 100644 --- a/courgette/disassembler_win32_x86.cc +++ b/courgette/disassembler_win32_x86.cc @@ -514,15 +514,11 @@ CheckBool DisassemblerWin32X86::ParseNonSectionFileRegion( if (incomplete_disassembly_) return true; - const uint8* start = OffsetToPointer(start_file_offset); - const uint8* end = OffsetToPointer(end_file_offset); - - const uint8* p = start; - - while (p < end) { - if (!program->EmitByteInstruction(*p)) + if (end_file_offset > start_file_offset) { + if (!program->EmitBytesInstruction(OffsetToPointer(start_file_offset), + end_file_offset - start_file_offset)) { return false; - ++p; + } } return true; |