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

Side by Side Diff: Source/platform/text/TextBoundaries.cpp

Issue 268363016: Improve the find word boundary performance (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add findWordEndBoundary Created 6 years, 5 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
« no previous file with comments | « Source/platform/text/TextBoundaries.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Dominik Röttsches <dominik.roettsches@access-company.com> 3 * Copyright (C) 2009 Dominik Röttsches <dominik.roettsches@access-company.com>
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 void findWordBoundary(const UChar* chars, int len, int position, int* start, int * end) 93 void findWordBoundary(const UChar* chars, int len, int position, int* start, int * end)
94 { 94 {
95 TextBreakIterator* it = wordBreakIterator(chars, len); 95 TextBreakIterator* it = wordBreakIterator(chars, len);
96 *end = it->following(position); 96 *end = it->following(position);
97 if (*end < 0) 97 if (*end < 0)
98 *end = it->last(); 98 *end = it->last();
99 *start = it->previous(); 99 *start = it->previous();
100 } 100 }
101 101
102 int findWordEndBoundary(const UChar* chars, int len, int position)
103 {
104 TextBreakIterator* it = wordBreakIterator(chars, len);
105 int end = it->following(position);
106 return end < 0 ? it->last() : end;
107 }
102 108
103 } // namespace blink 109 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/text/TextBoundaries.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698