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

Side by Side Diff: pkg/observe/lib/src/list_diff.dart

Issue 132403010: big update to observe, template_binding, polymer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library observe.src.list_diff; 5 library observe.src.list_diff;
6 6
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 import 'dart:collection' show UnmodifiableListView; 8 import 'dart:collection' show UnmodifiableListView;
9 9
10 /** 10 /**
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 * model.insertAll(0, ['c', 'd', 'e']); 374 * model.insertAll(0, ['c', 'd', 'e']);
375 * model.removeRange(1, 3); 375 * model.removeRange(1, 3);
376 * model.insert(1, 'f'); 376 * model.insert(1, 'f');
377 * 377 *
378 * Here, we inserted some records and then removed some of them. 378 * Here, we inserted some records and then removed some of them.
379 * If someone processed these records naively, they would "play back" the 379 * If someone processed these records naively, they would "play back" the
380 * insert incorrectly, because those items will be shifted. 380 * insert incorrectly, because those items will be shifted.
381 */ 381 */
382 List<ListChangeRecord> projectListSplices(List list, 382 List<ListChangeRecord> projectListSplices(List list,
383 List<ListChangeRecord> records) { 383 List<ListChangeRecord> records) {
384 if (records.length == 1) return records; 384 if (records.length <= 1) return records;
385 385
386 var splices = []; 386 var splices = [];
387 for (var splice in _createInitialSplices(list, records)) { 387 for (var splice in _createInitialSplices(list, records)) {
388 if (splice.addedCount == 1 && splice.removed.length == 1) { 388 if (splice.addedCount == 1 && splice.removed.length == 1) {
389 if (splice.removed[0] != list[splice.index]) splices.add(splice); 389 if (splice.removed[0] != list[splice.index]) splices.add(splice);
390 continue; 390 continue;
391 } 391 }
392 392
393 splices.addAll(calcSplices(list, splice.index, 393 splices.addAll(calcSplices(list, splice.index,
394 splice.index + splice.addedCount, splice._removed, 0, 394 splice.index + splice.addedCount, splice._removed, 0,
395 splice.removed.length)); 395 splice.removed.length));
396 } 396 }
397 397
398 return splices; 398 return splices;
399 } 399 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698