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

Unified Diff: runtime/lib/string_patch.dart

Issue 14703005: Added Object._cid getter, optimized it. Added to (some) classes a static final _clCid. Use those to… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: runtime/lib/string_patch.dart
===================================================================
--- runtime/lib/string_patch.dart (revision 22603)
+++ runtime/lib/string_patch.dart (working copy)
@@ -29,16 +29,17 @@
static String createFromCharCodes(Iterable<int> charCodes) {
if (charCodes != null) {
// TODO(srdjan): Also skip copying of typed arrays.
- if (charCodes is! _ObjectArray &&
- charCodes is! _GrowableObjectArray &&
- charCodes is! _ImmutableArray) {
+ final ccid = charCodes._cid;
+ if ((ccid != _ObjectArray._clCid) &&
+ (ccid != _GrowableObjectArray._clCid) &&
+ (ccid != _ImmutableArray._clCid)) {
siva 2013/05/13 20:38:00 It might be more readable to have static methods i
srdjan 2013/05/14 17:46:31 I am open to change it, but I think this is more r
charCodes = new List<int>.from(charCodes, growable: false);
}
bool isOneByteString = true;
for (int i = 0; i < charCodes.length; i++) {
int e = charCodes[i];
- if (e is! int) throw new ArgumentError(e);
+ if (e is! _Smi) throw new ArgumentError(e);
// Is e Latin1?
if ((e < 0) || (e > 0xFF)) {
isOneByteString = false;
@@ -342,7 +343,7 @@
int totalLength = 0;
for (int i = 0; i < numValues; i++) {
var s = values[i].toString();
- if (isOneByteString && (s is _OneByteString)) {
+ if (isOneByteString && (s._cid == _OneByteString._clCid)) {
siva 2013/05/13 20:38:00 Object.IsOneByteString(s);
srdjan 2013/05/14 17:46:31 Next CL as discussed offline.
totalLength += s.length;
} else {
isOneByteString = false;
@@ -448,11 +449,11 @@
final len = strings.length;
bool isOneByteString = true;
int totalLength = 0;
- if (strings is _ObjectArray) {
+ if (strings._cid == _ObjectArray._clCId) {
stringsArray = strings;
for (int i = 0; i < len; i++) {
var string = strings[i];
- if (string is _OneByteString) {
+ if (string._cid == _OneByteString._clCid) {
totalLength += string.length;
} else {
isOneByteString = false;
@@ -465,7 +466,7 @@
int i = 0;
for (int i = 0; i < len; i++) {
var string = strings[i];
- if (string is _OneByteString) {
+ if (string._cid == _OneByteString.clCid) {
totalLength += s.length;
} else {
isOneByteString = false;
@@ -485,7 +486,7 @@
final stringsLength = strings.length;
for (int i = 0; i < stringsLength; i++) {
var e = strings[i];
- if (e is! _OneByteString) {
+ if (e._cid != _OneByteString._clCid) {
return _concatAllNative(strings);
}
totalLength += e.length;
@@ -500,6 +501,8 @@
class _OneByteString extends _StringBase implements String {
+ static final int _clCid = "A"._cid;
+
factory _OneByteString._uninstantiable() {
throw new UnsupportedError(
"_OneByteString can only be allocated by the VM");
@@ -523,7 +526,7 @@
native "OneByteString_splitWithCharCode";
List<String> split(Pattern pattern) {
- if ((pattern is _OneByteString) && (pattern.length == 1)) {
+ if ((pattern._cid == _OneByteString._clCid) && (pattern.length == 1)) {
return _splitWithCharCode(pattern.codeUnitAt(0));
}
return super.split(pattern);

Powered by Google App Engine
This is Rietveld 408576698