Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(907)

Side by Side Diff: third_party/WebKit/Source/platform/wtf/text/TextCodecUTF16.cpp

Issue 2833123002: Replace ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/wtf (Closed)
Patch Set: wtf Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 } 183 }
184 184
185 return result; 185 return result;
186 } 186 }
187 187
188 CString TextCodecUTF16::Encode(const LChar* characters, 188 CString TextCodecUTF16::Encode(const LChar* characters,
189 size_t length, 189 size_t length,
190 UnencodableHandling) { 190 UnencodableHandling) {
191 // In the LChar case, we do actually need to perform this check in release. :) 191 // In the LChar case, we do actually need to perform this check in release. :)
192 RELEASE_ASSERT(length <= numeric_limits<size_t>::max() / 2); 192 CHECK_LE(length, numeric_limits<size_t>::max() / 2);
193 193
194 char* bytes; 194 char* bytes;
195 CString result = CString::CreateUninitialized(length * 2, bytes); 195 CString result = CString::CreateUninitialized(length * 2, bytes);
196 196
197 if (little_endian_) { 197 if (little_endian_) {
198 for (size_t i = 0; i < length; ++i) { 198 for (size_t i = 0; i < length; ++i) {
199 bytes[i * 2] = characters[i]; 199 bytes[i * 2] = characters[i];
200 bytes[i * 2 + 1] = 0; 200 bytes[i * 2 + 1] = 0;
201 } 201 }
202 } else { 202 } else {
203 for (size_t i = 0; i < length; ++i) { 203 for (size_t i = 0; i < length; ++i) {
204 bytes[i * 2] = 0; 204 bytes[i * 2] = 0;
205 bytes[i * 2 + 1] = characters[i]; 205 bytes[i * 2 + 1] = characters[i];
206 } 206 }
207 } 207 }
208 208
209 return result; 209 return result;
210 } 210 }
211 211
212 } // namespace WTF 212 } // namespace WTF
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698