| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:collection'; | 5 import 'dart:collection'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Implementation of [Uri] that understands only a limited set of valid | 8 * Implementation of [Uri] that understands only a limited set of valid |
| 9 * URI formats, but works fast. In practice Dart code almost always uses such | 9 * URI formats, but works fast. In practice Dart code almost always uses such |
| 10 * limited URI format, so almost always can be processed fast. | 10 * limited URI format, so almost always can be processed fast. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 @override | 55 @override |
| 56 bool get hasAuthority => _hasEmptyAuthority; | 56 bool get hasAuthority => _hasEmptyAuthority; |
| 57 | 57 |
| 58 @override | 58 @override |
| 59 bool get hasEmptyPath => _path.isEmpty; | 59 bool get hasEmptyPath => _path.isEmpty; |
| 60 | 60 |
| 61 @override | 61 @override |
| 62 bool get hasFragment => false; | 62 bool get hasFragment => false; |
| 63 | 63 |
| 64 @override | 64 @override |
| 65 int get hashCode { | 65 int get hashCode => _text.hashCode; |
| 66 // This code is copied from the standard Uri implementation. | |
| 67 // It is important that Uri and FastUri generate compatible hashCodes | |
| 68 // because Uri and FastUri may be used as keys in the same map. | |
| 69 int combine(part, current) { | |
| 70 // The sum is truncated to 30 bits to make sure it fits into a Smi. | |
| 71 return (current * 31 + part.hashCode) & 0x3FFFFFFF; | |
| 72 } | |
| 73 return _hashCode ??= combine( | |
| 74 scheme, | |
| 75 combine( | |
| 76 userInfo, | |
| 77 combine( | |
| 78 host, | |
| 79 combine(port, | |
| 80 combine(path, combine(query, combine(fragment, 1))))))); | |
| 81 } | |
| 82 | 66 |
| 83 @override | 67 @override |
| 84 bool get hasPort => false; | 68 bool get hasPort => false; |
| 85 | 69 |
| 86 @override | 70 @override |
| 87 bool get hasQuery => false; | 71 bool get hasQuery => false; |
| 88 | 72 |
| 89 @override | 73 @override |
| 90 bool get hasScheme => _scheme.isNotEmpty; | 74 bool get hasScheme => _scheme.isNotEmpty; |
| 91 | 75 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 hasEmptyAuthority = true; | 266 hasEmptyAuthority = true; |
| 283 path = path.substring(2); | 267 path = path.substring(2); |
| 284 if (!path.startsWith('/')) { | 268 if (!path.startsWith('/')) { |
| 285 return null; | 269 return null; |
| 286 } | 270 } |
| 287 } | 271 } |
| 288 return new FastUri._(_currentCacheGeneration, text, scheme, | 272 return new FastUri._(_currentCacheGeneration, text, scheme, |
| 289 hasEmptyAuthority, path, lastSlashIndex); | 273 hasEmptyAuthority, path, lastSlashIndex); |
| 290 } | 274 } |
| 291 } | 275 } |
| OLD | NEW |