| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 class StringBuilder { | 177 class StringBuilder { |
| 178 public: | 178 public: |
| 179 // Create a string builder with a buffer of the given size. The | 179 // Create a string builder with a buffer of the given size. The |
| 180 // buffer is allocated through NewArray<char> and must be | 180 // buffer is allocated through NewArray<char> and must be |
| 181 // deallocated by the caller of Finalize(). | 181 // deallocated by the caller of Finalize(). |
| 182 explicit StringBuilder(int size); | 182 explicit StringBuilder(int size); |
| 183 | 183 |
| 184 StringBuilder(char* buffer, int size) | 184 StringBuilder(char* buffer, int size) |
| 185 : buffer_(buffer, size), position_(0) { } | 185 : buffer_(buffer, size), position_(0) { } |
| 186 | 186 |
| 187 ~StringBuilder() { if (!is_finalized()) buffer_.Dispose(); } | 187 ~StringBuilder() { if (!is_finalized()) Finalize(); } |
| 188 | 188 |
| 189 int size() const { return buffer_.length(); } | 189 int size() const { return buffer_.length(); } |
| 190 | 190 |
| 191 // Get the current position in the builder. | 191 // Get the current position in the builder. |
| 192 int position() const { | 192 int position() const { |
| 193 ASSERT(!is_finalized()); | 193 ASSERT(!is_finalized()); |
| 194 return position_; | 194 return position_; |
| 195 } | 195 } |
| 196 | 196 |
| 197 // Reset the position. | 197 // Reset the position. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 292 } |
| 293 #endif | 293 #endif |
| 294 while (dest < limit) { | 294 while (dest < limit) { |
| 295 *dest++ = static_cast<sinkchar>(*src++); | 295 *dest++ = static_cast<sinkchar>(*src++); |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 } } // namespace v8::internal | 299 } } // namespace v8::internal |
| 300 | 300 |
| 301 #endif // V8_V8UTILS_H_ | 301 #endif // V8_V8UTILS_H_ |
| OLD | NEW |