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

Side by Side Diff: pkg/analysis_server/lib/src/services/correction/diff.dart

Issue 626883003: Fix for the prefix/suffix diff computing. (Closed) Base URL: https://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 | pkg/analysis_server/lib/src/services/correction/sort_members.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 library diff;
6
7 import 'dart:math';
8
9
10 /**
11 * Return the number of characters common to the start of [a] and [b].
12 */
13 int findCommonPrefix(String a, String b) {
14 int n = min(a.length, b.length);
15 for (int i = 0; i < n; i++) {
16 if (a.codeUnitAt(i) != b.codeUnitAt(i)) {
17 return i;
18 }
19 }
20 return n;
21 }
22
23
24 /**
25 * Return the number of characters common to the end of [a] and [b].
26 */
27 int findCommonSuffix(String a, String b) {
28 int a_length = a.length;
29 int b_length = b.length;
30 int n = min(a_length, b_length);
31 for (int i = 1; i <= n; i++) {
32 if (a.codeUnitAt(a_length - i) != b.codeUnitAt(b_length - i)) {
33 return i - 1;
34 }
35 }
36 return n;
37 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/correction/sort_members.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698