Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file contains the code to apply a Courgette patch. | 5 // This file contains the code to apply a Courgette patch. |
| 6 | 6 |
| 7 #include "courgette/ensemble.h" | 7 #include "courgette/ensemble.h" |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 correction, | 213 correction, |
| 214 corrected_elements, | 214 corrected_elements, |
| 215 &corrected_elements_storage_); | 215 &corrected_elements_storage_); |
| 216 } | 216 } |
| 217 | 217 |
| 218 Status EnsemblePatchApplication::TransformDown( | 218 Status EnsemblePatchApplication::TransformDown( |
| 219 SourceStreamSet* transformed_elements, | 219 SourceStreamSet* transformed_elements, |
| 220 SinkStream* basic_elements) { | 220 SinkStream* basic_elements) { |
| 221 // Construct blob of original input followed by reformed elements. | 221 // Construct blob of original input followed by reformed elements. |
| 222 | 222 |
| 223 basic_elements->Reserve(final_patch_input_size_prediction_); | 223 if (final_patch_input_size_prediction_ && |
|
robertshield
2011/03/22 18:04:07
Even though this looks right, this is a functional
tommi (sloooow) - chröme
2011/03/22 18:37:49
Removed the first check to maintain the previous f
| |
| 224 !basic_elements->Reserve(final_patch_input_size_prediction_)) { | |
| 225 return C_STREAM_ERROR; | |
| 226 } | |
| 224 | 227 |
| 225 // The original input: | 228 // The original input: |
| 226 basic_elements->Write(base_region_.start(), base_region_.length()); | 229 if (!basic_elements->Write(base_region_.start(), base_region_.length())) |
| 230 return C_STREAM_ERROR; | |
| 227 | 231 |
| 228 for (size_t i = 0; i < patchers_.size(); ++i) { | 232 for (size_t i = 0; i < patchers_.size(); ++i) { |
| 229 SourceStreamSet single_corrected_element; | 233 SourceStreamSet single_corrected_element; |
| 230 if (!transformed_elements->ReadSet(&single_corrected_element)) | 234 if (!transformed_elements->ReadSet(&single_corrected_element)) |
| 231 return C_STREAM_ERROR; | 235 return C_STREAM_ERROR; |
| 232 Status status = patchers_[i]->Reform(&single_corrected_element, | 236 Status status = patchers_[i]->Reform(&single_corrected_element, |
| 233 basic_elements); | 237 basic_elements); |
| 234 if (status != C_OK) | 238 if (status != C_OK) |
| 235 return status; | 239 return status; |
| 236 if (!single_corrected_element.Empty()) | 240 if (!single_corrected_element.Empty()) |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 static_cast<int>(new_sink_stream.Length())); | 407 static_cast<int>(new_sink_stream.Length())); |
| 404 if (written == -1) | 408 if (written == -1) |
| 405 return C_WRITE_OPEN_ERROR; | 409 return C_WRITE_OPEN_ERROR; |
| 406 if (static_cast<size_t>(written) != new_sink_stream.Length()) | 410 if (static_cast<size_t>(written) != new_sink_stream.Length()) |
| 407 return C_WRITE_ERROR; | 411 return C_WRITE_ERROR; |
| 408 | 412 |
| 409 return C_OK; | 413 return C_OK; |
| 410 } | 414 } |
| 411 | 415 |
| 412 } // namespace | 416 } // namespace |
| OLD | NEW |