John McCutchan
5590ba31be
Shrink growable arrays
...
Fixes #25778
Review URL: https://codereview.chromium.org/1701213002 .
2016-02-17 13:20:53 -08:00
Lasse R.H. Nielsen
d755dd65b9
Update range errors to agree on the numbers.
...
Also ensure that typed-data errors are consistent with other lists.
Fixes issue #24295
BUG= http://dartbug.com/24295
R=floitsch@google.com , iposva@google.com , sra@google.com
Review URL: https://codereview.chromium.org//1318943005 .
2015-09-11 13:05:36 +02:00
Lasse R.H. Nielsen
babcd4e9c0
Revert "Make EfficientLength public, as EfficientLengthIterable."
...
It's still not a good solution for detecting an Iterable with an efficient
length. It's not inherited by, e.g., a DelegatingIterable wrapper or similar
generic Iterable transformers.
Keep this as an internal optimization for quickly detecting the most common
efficient-length Iterable classes (List, Set, Queue, Map.keys/values), but
don't make it public.
A *real* solution would be adding a hasEfficientLength getter to Iterable, or
adding an efficientLength getter that may return null if it's not efficient.
This would something that a wrapper can attach to.
R=sgjesse@google.com
Review URL: https://codereview.chromium.org//1154263003
2015-05-29 12:52:45 +02:00
lrn@google.com
92c526b2a2
Make EfficientLength public, as EfficientLengthIterable.
...
R=iposva@google.com , sgjesse@google.com
Review URL: https://codereview.chromium.org//1104063002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45556 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-06 09:00:45 +00:00
srdjan@google.com
0b094880cc
Improve performance of addAll for internallt known lists.
...
Review URL: https://codereview.chromium.org//873863002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43154 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-26 21:50:40 +00:00
turnidge@google.com
92211b622a
Minor optimization in _GrowableList.removeAt.
...
BUG=
R=srdjan@google.com
Review URL: https://codereview.chromium.org//790873002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42214 260f80e4-7a28-3924-810f-c04153c831b5
2014-12-09 19:11:41 +00:00
fschneider@google.com
a49870e721
VM: Remove use of IterableMixinWorkaround from _List, _ImmutableList and _GrowableList.
...
_List, _ImmutableList and _GrowableList now extend ListBase which uses ListMixin.
Note that typed data lists are still using IterableMixinWorkaround for now.
They will be changed in a separate CL since it involves a few more changes
to the VM.
BUG=dartbug.com/13647
R=lrn@google.com
Review URL: https://codereview.chromium.org//730543002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42061 260f80e4-7a28-3924-810f-c04153c831b5
2014-12-02 10:38:51 +00:00
lrn@google.com
28937c86ae
Optimize _GrowableArray._join and _StringBase._interpolate.
...
R=fschneider@google.com
Review URL: https://codereview.chromium.org//551823002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40800 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-30 08:28:00 +00:00
ajohnsen@google.com
f75e71d95c
Remove unused string interpolations.
...
BUG=
R=lrn@google.com
Review URL: https://codereview.chromium.org//532233002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39802 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-03 12:35:50 +00:00
lrn@google.com
7947f84054
Optimize List.toList/.sublist and List.from on lists.
...
R=fschneider@google.com , srdjan@google.com
Review URL: https://codereview.chromium.org//485043002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39579 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-27 08:00:48 +00:00
lrn@google.com
729de01f79
Make IterableMixinWorkaround using classes return correctly typed Iterables.
...
BUG= http://dartbug.com/13646
R=floitsch@google.com
Review URL: https://codereview.chromium.org//397243002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38372 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-18 08:08:16 +00:00
srdjan@google.com
97021b5861
Add class id constants fields to dart:_internal class 'ClassID'. Use the fields in the library (more uses to come).
...
R=asiva@google.com
Review URL: https://codereview.chromium.org//351673002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37628 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-23 22:41:59 +00:00
srdjan@google.com
d44423b766
Add VM internal Dart class 'ClassID' used to manage class-ids of known classes. Next CL: add constant fields corresponding to each class id (smiCid, oneByteStringCid, etc).
...
R=asiva@google.com
Review URL: https://codereview.chromium.org//345223003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37567 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-20 20:56:55 +00:00
srdjan@google.com
ee210974f6
Reduce default capacity of growable list from 4 to 2 elements. Improves performance.
...
R=asiva@google.com
Review URL: https://codereview.chromium.org//337383004
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37421 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-17 20:49:47 +00:00
lrn@google.com
1ec6c5c1db
Revert "Add "last" setter to List."
...
After discussion, we decided not to change the List interface for something that is just a convenience.
Also revert "Mark pkgbuild/pkg/collection as failing when using repository packages"
R=sgjesse@google.com
Review URL: https://codereview.chromium.org//331833003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37307 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-13 09:40:22 +00:00
lrn@google.com
f528beb9f2
Add "last" setter to List.
...
This allows assigning directly as `list.last = value` instead of
having to use the longer `list[list.length - 1] = value`.
It's just an abbreviation, like `list.last` is for reading.
If you use a List as a stack (which is a perfectly good use of it),
modifying the last element like this is a natural operation.
R=sgjesse@google.com
Review URL: https://codereview.chromium.org//315173005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37255 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-12 08:11:22 +00:00
lrn@google.com
989709f3a8
Reinstall previous behavior for Set and Queue toString.
...
A previous change made these omit elements to keep the toString length down.
That could break code that expects the original behavior.
This still avoids using IterableMixinWorkaround.
Add static toString methods on ListBase, SetBase, IterableBase so that users can
get the same behavior as our toString methods, and with the same cycle detection
safety.
Unify all collection toString methods in two methods:
- IterableBase.iterableToShortString
- IterableBase.iterableToFullString
R=floitsch@google.com
Review URL: https://codereview.chromium.org//297053002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36616 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-26 06:08:20 +00:00
iposva@google.com
5a469c41b3
- Remove unnecessary is-check.
...
- Other formatting cleanup.
R=srdjan@google.com
Review URL: https://codereview.chromium.org//280843002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36192 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-14 22:21:48 +00:00
lrn@google.com
f449a85d1e
Unify error messages for iterables and lists.
...
Add factory methods that generate the errors thrown for unmodifiable lists,
non-growable lists and iterations with the wrong number of elements.
R=iposva@google.com , sgjesse@google.com
Review URL: https://codereview.chromium.org//262803003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35733 260f80e4-7a28-3924-810f-c04153c831b5
2014-05-05 09:26:56 +00:00
ngeoffray@google.com
2015e5f204
Fix an old TODO.
...
R=floitsch@google.com
Review URL: https://codereview.chromium.org//107333003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@31253 260f80e4-7a28-3924-810f-c04153c831b5
2013-12-19 10:40:53 +00:00
hausner@google.com
c96bc29ab5
Compile time error if name is used before variable is declared
...
Implement proper semantics if a name has been referenced in a
block and later a variable with that same name is declared.
Fix library code that was wrong.
Add new language test, delete a couple of tests that are
outdated, file co19 bug 649.
Dart2js and dart2dart are not yet implementing these compile-time
errors.
R=iposva@google.com
Review URL: https://codereview.chromium.org//51533003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29770 260f80e4-7a28-3924-810f-c04153c831b5
2013-11-01 21:28:31 +00:00
lrn@google.com
e3713a08d4
Make List.shuffle take an optional Random object to use.
...
R=floitsch@google.com
Review URL: https://codereview.chromium.org//25931003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28305 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-07 12:07:30 +00:00
lrn@google.com
55a8a72ca6
Add List.shuffle().
...
Will add tests too.
R=floitsch@google.com
Review URL: https://codereview.chromium.org//24740003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28206 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-03 11:09:01 +00:00
iposva@google.com
e7e2e4bf03
- Rename arrays to lists:
...
_ObjectArray -> _List
_GrowableObjectArray -> _GrowableList
_ImmutableArray -> _ImmutableList
R=srdjan@google.com
Review URL: https://codereview.chromium.org//25813002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28189 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-03 00:15:14 +00:00
zarah@google.com
93bcd6baf7
Move toString() to collection classes.
...
R=floitsch@google.com
Committed: https://code.google.com/p/dart/source/detail?r=24836
Review URL: https://codereview.chromium.org//18837002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24913 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-11 12:59:12 +00:00
zarah@google.com
a0c76e6d43
Revert "Move toString() to collection classes."
...
This reverts commit 24836
Review URL: https://codereview.chromium.org//18282008
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24837 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-09 09:36:47 +00:00
zarah@google.com
8ed47ae514
Move toString() to collection classes.
...
R=floitsch@google.com
Review URL: https://codereview.chromium.org//18837002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24836 260f80e4-7a28-3924-810f-c04153c831b5
2013-07-09 08:35:54 +00:00
floitsch@google.com
48b1656690
Allow Object when doing lookups.
...
According to our typing rules a Set<Apple> is a Set<Fruit>. However, before this change, we couldn't use it as a Set<Fruit>:
===
bool foo(Set<Fruit> fruits) {
// Would yield a type-error since we actually got a Set<Apple>.
return fruits.contains(new Banana());
}
foo(new Set<Apple>());
===
R=ajohnsen@google.com , blois@google.com , lrn@google.com
Review URL: https://codereview.chromium.org//14246008
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24326 260f80e4-7a28-3924-810f-c04153c831b5
2013-06-24 12:45:10 +00:00
floitsch@google.com
5d058bb0eb
Adding isNotEmpty property to collection and string.
...
BUG= http://dartbug.com/3074
R=floitsch@google.com
Review URL: https://codereview.chromium.org//15263004
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23294 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-28 17:30:37 +00:00
srdjan@google.com
7797d39362
Added Object._cid getter, optimized it. Added to (some) classes a static final _clCid. Use those to test for exact type in VM's libraries.
...
R=iposva@google.com
Review URL: https://codereview.chromium.org//14703005
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22695 260f80e4-7a28-3924-810f-c04153c831b5
2013-05-14 18:16:44 +00:00
lrn@google.com
e0e13fe852
Fix missing concurrency check in [].forEach.
...
Also fix a bad range check for List.setRange.
Added more tests.
BUG=http://dartbug.com/10045
Review URL: https://codereview.chromium.org//14468004
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21935 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-24 09:34:17 +00:00
lrn@google.com
554a845e4f
Make List.remove return boolean.
...
Remove Queue implementations' remove methods, which are not in the
interface.
Added more tests for list operations.
Fixed bugs and omissions found by tests.
http://dartbug.com/10042
http://dartbug.com/10112
Review URL: https://codereview.chromium.org//14425003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21867 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-23 11:13:17 +00:00
srdjan@google.com
2e0bba73fe
Do not set growable array length unnecessarily.
...
Review URL: https://codereview.chromium.org//14265015
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21526 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 23:00:06 +00:00
floitsch@google.com
1049521aaa
Add setAll, insertAll, replaceRange and fillRange.
...
BUG=
Review URL: https://codereview.chromium.org//14175013
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21471 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 16:25:21 +00:00
floitsch@google.com
759a366cea
Remove insertRange.
...
Review URL: https://codereview.chromium.org//13956006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21464 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 15:20:16 +00:00
floitsch@google.com
9bfc844930
Refactor removeRange.
...
Review URL: https://codereview.chromium.org//13872007
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21462 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 15:10:23 +00:00
floitsch@google.com
bebe3ac2cd
Refactor List.setRange function.
...
Review URL: https://codereview.chromium.org//13863012
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21452 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-15 13:52:29 +00:00
ajohnsen@google.com
044f0d02eb
Remove Collection, Collections and clean up List/Set/Queue implementations of retain/remove.
...
BUG=
Review URL: https://codereview.chromium.org//14173003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21338 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-12 09:34:52 +00:00
floitsch@google.com
aecbeabcac
Implement getRange (returning an Iterable).
...
Review URL: https://codereview.chromium.org//14065011
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21281 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-11 14:14:29 +00:00
lrn@google.com
f41508d33b
Added new version of reduce.
...
Removed min/max and uses of min/max.
Review URL: https://codereview.chromium.org//14071002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21258 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-11 08:32:31 +00:00
floitsch@google.com
62358bf5e2
Make default argument to Iterable.join be "".
...
Review URL: https://codereview.chromium.org//13945009
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21193 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-10 11:28:32 +00:00
lrn@google.com
6160e59850
Moving ListBase, FixedLengthListMixin and UmodifiableListMixin to collection.
...
Users can now create lists easily by extending these classes, just
as they can create iterables by extending Iterable.
Reduce the dependency of IterableMixinWorkaround outside of core/collection
implementations. I plan to move IterableMixinWorkaround to _collection-dev
before M4.
Review URL: https://codereview.chromium.org//13774006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21147 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-09 12:11:05 +00:00
floitsch@google.com
bef8ebb5f6
Add Iterable.fold (and Stream.fold) which replace reduce.
...
For now this is just a copy. In a next step we will change the behavior of
`reduce`.
BUG= http://dartbug.com/9536
Review URL: https://codereview.chromium.org//13548002
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20978 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-05 16:12:40 +00:00
lrn@google.com
3b13f62170
Remove addLast from List.
...
The List.addLast method has been deprecated for quite a while.
A recent change removed it from the interface, but left the
implementation in place (which caused some errors from the analyzer).
This removes it completely.
Review URL: https://codereview.chromium.org//13528004
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20857 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-03 12:52:19 +00:00
lrn@google.com
844cd39fad
Change getRange to sublist. Make getRange deprecated.
...
This changes the exception behavior of getRange. It used to accept
a length of zero, no matter what start value. Now the start value
must be a valid list index.
Review URL: https://codereview.chromium.org//12817003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20064 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-15 09:15:39 +00:00
floitsch@google.com
76d507cb6f
Add List.insert.
...
BUG= http://dartbug.com/5375
Review URL: https://codereview.chromium.org//12383073
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20037 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-14 17:38:14 +00:00
floitsch@google.com
65718c56df
Rename XMatching to XWhere.
...
For example firstMatching -> firstWhere.
BUG= http://dartbug.com/8664
BUG= http://dartbug.com/8337
Review URL: https://codereview.chromium.org//12537009
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19880 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-12 17:34:49 +00:00
floitsch@google.com
dd48256fe5
Remove deprecated StringBuffer.add, addAll and addCharCode.
...
Review URL: https://codereview.chromium.org//12473003
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19690 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-08 13:07:18 +00:00
floitsch@google.com
fd28ec5b2e
Move Arrays class to private library.
...
Committed: https://code.google.com/p/dart/source/detail?r=19375
Reverted: http://code.google.com/p/dart/source/detail?r=19420
Review URL: https://codereview.chromium.org//12386072
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19476 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-05 13:24:55 +00:00
floitsch@google.com
5505496990
Revert "Move Arrays class to private library."
...
This reverts commit 19375.
Review URL: https://codereview.chromium.org//12379085
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19420 260f80e4-7a28-3924-810f-c04153c831b5
2013-03-04 21:27:38 +00:00