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

Side by Side Diff: runtime/vm/object.cc

Issue 620493004: Fix corner case in partial script url matching (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 9094 matching lines...) Expand 10 before | Expand all | Expand 10 after
9105 const Array& scripts_array = Array::Handle(Array::MakeArray(scripts)); 9105 const Array& scripts_array = Array::Handle(Array::MakeArray(scripts));
9106 StorePointer(&raw_ptr()->loaded_scripts_, scripts_array.raw()); 9106 StorePointer(&raw_ptr()->loaded_scripts_, scripts_array.raw());
9107 } 9107 }
9108 return loaded_scripts(); 9108 return loaded_scripts();
9109 } 9109 }
9110 9110
9111 9111
9112 // TODO(hausner): we might want to add a script dictionary to the 9112 // TODO(hausner): we might want to add a script dictionary to the
9113 // library class to make this lookup faster. 9113 // library class to make this lookup faster.
9114 RawScript* Library::LookupScript(const String& url) const { 9114 RawScript* Library::LookupScript(const String& url) const {
9115 const intptr_t url_length = url.Length();
9116 if (url_length == 0) {
9117 return Script::null();
9118 }
9115 const Array& scripts = Array::Handle(LoadedScripts()); 9119 const Array& scripts = Array::Handle(LoadedScripts());
9116 Script& script = Script::Handle(); 9120 Script& script = Script::Handle();
9117 String& script_url = String::Handle(); 9121 String& script_url = String::Handle();
9118 const intptr_t url_length = url.Length();
9119 const intptr_t num_scripts = scripts.Length(); 9122 const intptr_t num_scripts = scripts.Length();
9120 for (int i = 0; i < num_scripts; i++) { 9123 for (int i = 0; i < num_scripts; i++) {
9121 script ^= scripts.At(i); 9124 script ^= scripts.At(i);
9122 script_url = script.url(); 9125 script_url = script.url();
9123 const intptr_t start_idx = script_url.Length() - url_length; 9126 const intptr_t start_idx = script_url.Length() - url_length;
9124 if ((start_idx == 0) && url.Equals(script_url)) { 9127 if ((start_idx == 0) && url.Equals(script_url)) {
9125 return script.raw(); 9128 return script.raw();
9126 } else if (start_idx > 0) { 9129 } else if (start_idx > 0) {
9127 // If we do a suffix match, only match if the partial path 9130 // If we do a suffix match, only match if the partial path
9128 // starts at or immediately after the path separator. 9131 // starts at or immediately after the path separator.
(...skipping 11156 matching lines...) Expand 10 before | Expand all | Expand 10 after
20285 return tag_label.ToCString(); 20288 return tag_label.ToCString();
20286 } 20289 }
20287 20290
20288 20291
20289 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20292 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20290 Instance::PrintJSONImpl(stream, ref); 20293 Instance::PrintJSONImpl(stream, ref);
20291 } 20294 }
20292 20295
20293 20296
20294 } // namespace dart 20297 } // namespace dart
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