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

Side by Side Diff: src/objects-inl.h

Issue 42115: Faster string.replace with regexp pattern. (Closed)
Patch Set: Addressed review comments Created 11 years, 9 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 // 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 2298 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 2309
2310 2310
2311 JSRegExp::Type JSRegExp::TypeTag() { 2311 JSRegExp::Type JSRegExp::TypeTag() {
2312 Object* data = this->data(); 2312 Object* data = this->data();
2313 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; 2313 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED;
2314 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); 2314 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex));
2315 return static_cast<JSRegExp::Type>(smi->value()); 2315 return static_cast<JSRegExp::Type>(smi->value());
2316 } 2316 }
2317 2317
2318 2318
2319 int JSRegExp::CaptureCount() {
2320 switch (TypeTag()) {
2321 case ATOM:
2322 return 0;
2323 case IRREGEXP:
2324 return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value();
2325 default:
2326 UNREACHABLE();
2327 return -1;
2328 }
2329 }
2330
2331
2319 JSRegExp::Flags JSRegExp::GetFlags() { 2332 JSRegExp::Flags JSRegExp::GetFlags() {
2320 ASSERT(this->data()->IsFixedArray()); 2333 ASSERT(this->data()->IsFixedArray());
2321 Object* data = this->data(); 2334 Object* data = this->data();
2322 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kFlagsIndex)); 2335 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kFlagsIndex));
2323 return Flags(smi->value()); 2336 return Flags(smi->value());
2324 } 2337 }
2325 2338
2326 2339
2327 String* JSRegExp::Pattern() { 2340 String* JSRegExp::Pattern() {
2328 ASSERT(this->data()->IsFixedArray()); 2341 ASSERT(this->data()->IsFixedArray());
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 #undef WRITE_INT_FIELD 2573 #undef WRITE_INT_FIELD
2561 #undef READ_SHORT_FIELD 2574 #undef READ_SHORT_FIELD
2562 #undef WRITE_SHORT_FIELD 2575 #undef WRITE_SHORT_FIELD
2563 #undef READ_BYTE_FIELD 2576 #undef READ_BYTE_FIELD
2564 #undef WRITE_BYTE_FIELD 2577 #undef WRITE_BYTE_FIELD
2565 2578
2566 2579
2567 } } // namespace v8::internal 2580 } } // namespace v8::internal
2568 2581
2569 #endif // V8_OBJECTS_INL_H_ 2582 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/regexp-delay.js » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698