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

Side by Side Diff: src/objects.h

Issue 11200004: Static cast char* diff to int. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 7406 matching lines...) Expand 10 before | Expand all | Expand 10 after
7417 // first non-ascii character, rather than directly to the non-ascii character. 7417 // first non-ascii character, rather than directly to the non-ascii character.
7418 // If the return value is >= the passed length, the entire string was ASCII. 7418 // If the return value is >= the passed length, the entire string was ASCII.
7419 static inline int NonAsciiStart(const char* chars, int length) { 7419 static inline int NonAsciiStart(const char* chars, int length) {
7420 const char* start = chars; 7420 const char* start = chars;
7421 const char* limit = chars + length; 7421 const char* limit = chars + length;
7422 #ifdef V8_HOST_CAN_READ_UNALIGNED 7422 #ifdef V8_HOST_CAN_READ_UNALIGNED
7423 ASSERT(kMaxAsciiCharCode == 0x7F); 7423 ASSERT(kMaxAsciiCharCode == 0x7F);
7424 const uintptr_t non_ascii_mask = kUintptrAllBitsSet / 0xFF * 0x80; 7424 const uintptr_t non_ascii_mask = kUintptrAllBitsSet / 0xFF * 0x80;
7425 while (chars + sizeof(uintptr_t) <= limit) { 7425 while (chars + sizeof(uintptr_t) <= limit) {
7426 if (*reinterpret_cast<const uintptr_t*>(chars) & non_ascii_mask) { 7426 if (*reinterpret_cast<const uintptr_t*>(chars) & non_ascii_mask) {
7427 return chars - start; 7427 return static_cast<int>(chars - start);
7428 } 7428 }
7429 chars += sizeof(uintptr_t); 7429 chars += sizeof(uintptr_t);
7430 } 7430 }
7431 #endif 7431 #endif
7432 while (chars < limit) { 7432 while (chars < limit) {
7433 if (static_cast<uint8_t>(*chars) > kMaxAsciiCharCodeU) { 7433 if (static_cast<uint8_t>(*chars) > kMaxAsciiCharCodeU) {
7434 return chars - start; 7434 return static_cast<int>(chars - start);
7435 } 7435 }
7436 ++chars; 7436 ++chars;
7437 } 7437 }
7438 return chars - start; 7438 return static_cast<int>(chars - start);
7439 } 7439 }
7440 7440
7441 static inline bool IsAscii(const char* chars, int length) { 7441 static inline bool IsAscii(const char* chars, int length) {
7442 return NonAsciiStart(chars, length) >= length; 7442 return NonAsciiStart(chars, length) >= length;
7443 } 7443 }
7444 7444
7445 static inline int NonAsciiStart(const uc16* chars, int length) { 7445 static inline int NonAsciiStart(const uc16* chars, int length) {
7446 const uc16* limit = chars + length; 7446 const uc16* limit = chars + length;
7447 const uc16* start = chars; 7447 const uc16* start = chars;
7448 while (chars < limit) { 7448 while (chars < limit) {
7449 if (*chars > kMaxAsciiCharCodeU) return chars - start; 7449 if (*chars > kMaxAsciiCharCodeU) return static_cast<int>(chars - start);
7450 ++chars; 7450 ++chars;
7451 } 7451 }
7452 return chars - start; 7452 return static_cast<int>(chars - start);
7453 } 7453 }
7454 7454
7455 static inline bool IsAscii(const uc16* chars, int length) { 7455 static inline bool IsAscii(const uc16* chars, int length) {
7456 return NonAsciiStart(chars, length) >= length; 7456 return NonAsciiStart(chars, length) >= length;
7457 } 7457 }
7458 7458
7459 protected: 7459 protected:
7460 class ReadBlockBuffer { 7460 class ReadBlockBuffer {
7461 public: 7461 public:
7462 ReadBlockBuffer(unibrow::byte* util_buffer_, 7462 ReadBlockBuffer(unibrow::byte* util_buffer_,
(...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after
8953 } else { 8953 } else {
8954 value &= ~(1 << bit_position); 8954 value &= ~(1 << bit_position);
8955 } 8955 }
8956 return value; 8956 return value;
8957 } 8957 }
8958 }; 8958 };
8959 8959
8960 } } // namespace v8::internal 8960 } } // namespace v8::internal
8961 8961
8962 #endif // V8_OBJECTS_H_ 8962 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698