diff options
author | sgeerken <devnull@localhost> | 2012-06-26 18:52:33 +0200 |
---|---|---|
committer | sgeerken <devnull@localhost> | 2012-06-26 18:52:33 +0200 |
commit | 6540639179c4d6c5340ace56b33976dada3adbc8 (patch) | |
tree | 178cc9044836db0ca0dfac57e7c27dab54c0285c /dw/hyphenator.cc | |
parent | 202e5b6b44a0900967d7fb945415799738cf1881 (diff) |
some refactoring
Diffstat (limited to 'dw/hyphenator.cc')
-rw-r--r-- | dw/hyphenator.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/dw/hyphenator.cc b/dw/hyphenator.cc index 8f73bc80..998b7975 100644 --- a/dw/hyphenator.cc +++ b/dw/hyphenator.cc @@ -117,6 +117,16 @@ void Hyphenator::insertPattern (char *s) } /** + * Simple test to avoid much costs. Passing it does not mean that the word + * can be hyphenated. + */ +bool Hyphenator::isHyphenationCandidate (const char *word) +{ + // Short words aren't hyphenated. + return (strlen (word) > 4); // TODO UTF-8? +} + +/** * Given a word, returns a list of pieces, broken at the possible * hyphenation points. */ @@ -124,8 +134,7 @@ Vector <String> *Hyphenator::hyphenateWord(const char *word) { Vector <String> *pieces = new Vector <String> (1, true); - // Short words aren't hyphenated. - if (strlen (word) <= 4) { // TODO UTF-8? + if (!isHyphenationCandidate (word) <= 4) { pieces->put (new String (word)); return pieces; } |