OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 335 |
336 void Truncate(int length) { | 336 void Truncate(int length) { |
337 ASSERT(length <= length_); | 337 ASSERT(length <= length_); |
338 length_ = length; | 338 length_ = length; |
339 } | 339 } |
340 | 340 |
341 // Releases the array underlying this vector. Once disposed the | 341 // Releases the array underlying this vector. Once disposed the |
342 // vector is empty. | 342 // vector is empty. |
343 void Dispose() { | 343 void Dispose() { |
344 DeleteArray(start_); | 344 DeleteArray(start_); |
345 if (is_empty()) return; | |
346 start_ = NULL; | 345 start_ = NULL; |
347 length_ = 0; | 346 length_ = 0; |
348 } | 347 } |
349 | 348 |
350 inline Vector<T> operator+(int offset) { | 349 inline Vector<T> operator+(int offset) { |
351 ASSERT(offset < length_); | 350 ASSERT(offset < length_); |
352 return Vector<T>(start_ + offset, length_ - offset); | 351 return Vector<T>(start_ + offset, length_ - offset); |
353 } | 352 } |
354 | 353 |
355 // Factory method for creating empty vectors. | 354 // Factory method for creating empty vectors. |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 | 632 |
634 Dest dest; | 633 Dest dest; |
635 memcpy(&dest, &source, sizeof(dest)); | 634 memcpy(&dest, &source, sizeof(dest)); |
636 return dest; | 635 return dest; |
637 } | 636 } |
638 | 637 |
639 | 638 |
640 } } // namespace v8::internal | 639 } } // namespace v8::internal |
641 | 640 |
642 #endif // V8_UTILS_H_ | 641 #endif // V8_UTILS_H_ |
OLD | NEW |