[Lldb-commits] [PATCH] D68647: Simplify LZMA decoding by using ArrayRef::take_back

Konrad Wilhelm Kleine via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 8 07:48:28 PDT 2019


kwk created this revision.
kwk added a reviewer: labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Follow-up for D66791#inline-616303 <https://reviews.llvm.org/D66791#inline-616303>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68647

Files:
  lldb/source/Host/common/LZMA.cpp


Index: lldb/source/Host/common/LZMA.cpp
===================================================================
--- lldb/source/Host/common/LZMA.cpp
+++ lldb/source/Host/common/LZMA.cpp
@@ -76,7 +76,7 @@
 
   // Decode xz footer.
   lzma_ret xzerr = lzma_stream_footer_decode(
-      &opts, InputBuffer.data() + InputBuffer.size() - LZMA_STREAM_HEADER_SIZE);
+      &opts, InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE).data());
   if (xzerr != LZMA_OK) {
     return llvm::createStringError(llvm::inconvertibleErrorCode(),
                                    "lzma_stream_footer_decode()=%s",
@@ -94,11 +94,11 @@
   lzma_index *xzindex;
   uint64_t memlimit(UINT64_MAX);
   size_t inpos = 0;
-  xzerr =
-      lzma_index_buffer_decode(&xzindex, &memlimit, nullptr,
-                               InputBuffer.data() + InputBuffer.size() -
-                                   LZMA_STREAM_HEADER_SIZE - opts.backward_size,
-                               &inpos, InputBuffer.size());
+  xzerr = lzma_index_buffer_decode(
+      &xzindex, &memlimit, nullptr,
+      InputBuffer.take_back(LZMA_STREAM_HEADER_SIZE - opts.backward_size)
+          .data(),
+      &inpos, InputBuffer.size());
   if (xzerr != LZMA_OK) {
     return llvm::createStringError(llvm::inconvertibleErrorCode(),
                                    "lzma_index_buffer_decode()=%s",


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68647.223864.patch
Type: text/x-patch
Size: 1348 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191008/ebcb3d12/attachment.bin>


More information about the lldb-commits mailing list