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

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

Issue 615313004: Use simple prefix/suffix diff in members sorter. (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 library diff;
Brian Wilkerson 2014/10/02 13:48:57 missing copyright
2
3 import 'dart:math';
4
5
6 /**
7 * Return the number of characters common to the start of [a] and [b].
8 */
9 int findCommonPrefix(String a, String b) {
Brian Wilkerson 2014/10/02 13:48:57 These seem like they belong in our StringUtilities
10 int n = min(a.length, b.length);
11 for (int i = 0; i < n; i++) {
12 if (a.codeUnitAt(i) != b.codeUnitAt(i)) {
13 return i;
14 }
15 }
16 return n;
17 }
18
19
20 /**
21 * Return the number of characters common to the end of [a] and [b].
22 */
23 int findCommonSuffix(String a, String b) {
24 int a_length = a.length;
25 int b_length = b.length;
26 int n = min(a_length, b_length);
27 for (int i = 1; i <= n; i++) {
28 if (a.codeUnitAt(a_length - i) != b.codeUnitAt(b_length - i)) {
29 return i - 1;
30 }
31 }
32 return n;
33 }
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