Skip to content

Commit

Permalink
unicodes: Optimize code by using constexpr and removing unused globals
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed May 25, 2019
1 parent 23d05a5 commit 334d9b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 43 deletions.
35 changes: 4 additions & 31 deletions src/ccutil/unicodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,9 @@

namespace tesseract {

const char *kUTF8LineSeparator = "\u2028"; // "\xe2\x80\xa8";
const char *kUTF8ParagraphSeparator = "\u2029"; // "\xe2\x80\xa9";
const char *kLRM = "\u200E"; // Left-to-Right Mark
const char *kRLM = "\u200F"; // Right-to-Left Mark
const char *kRLE = "\u202A"; // Right-to-Left Embedding
const char *kPDF = "\u202C"; // Pop Directional Formatting

const char *kHyphenLikeUTF8[] = {
"-", // ASCII hyphen-minus
"\u05BE", // word hyphen in hybrew
"\u2010", // hyphen
"\u2011", // non-breaking hyphen
"\u2012", // a hyphen the same width as digits
"\u2013", // en dash
"\u2014", // em dash
"\u2015", // horizontal bar
"\u2212", // arithmetic minus sign
"\uFE58", // small em dash
"\uFE63", // small hyphen-minus
"\uFF0D", // fullwidth hyphen-minus
nullptr, // end of our list
};

const char *kApostropheLikeUTF8[] = {
"'", // ASCII apostrophe
"`", // ASCII backtick
"\u2018", // opening single quote
"\u2019", // closing single quote
"\u2032", // mathematical prime mark
nullptr, // end of our list.
};
constexpr const char *kLRM = "\u200E"; // Left-to-Right Mark
constexpr const char *kRLM = "\u200F"; // Right-to-Left Mark
constexpr const char *kRLE = "\u202A"; // Right-to-Left Embedding
constexpr const char *kPDF = "\u202C"; // Pop Directional Formatting

} // namespace
16 changes: 4 additions & 12 deletions src/ccutil/unicodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* File: unicodes.h
* Description: Unicode related machinery
* Author: David Eger
* Created: Wed Jun 15 16:37:50 PST 2011
*
* (C) Copyright 2011, Google, Inc.
** Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,17 +21,10 @@

namespace tesseract {

extern const char *kUTF8LineSeparator;
extern const char *kUTF8ParagraphSeparator;
extern const char *kLRM; ///< Left-to-Right Mark
extern const char *kRLM; ///< Right-to-Left Mark
extern const char *kRLE; ///< Right-to-Left Embedding
extern const char *kPDF; ///< Pop Directional Formatting

/// The following are confusable internal word punctuation symbols
/// which we normalize to the first variant when matching in dawgs.
extern const char *kHyphenLikeUTF8[];
extern const char *kApostropheLikeUTF8[];
extern const char* const kLRM; ///< Left-to-Right Mark
extern const char* const kRLM; ///< Right-to-Left Mark
extern const char* const kRLE; ///< Right-to-Left Embedding
extern const char* const kPDF; ///< Pop Directional Formatting

} // namespace

Expand Down

0 comments on commit 334d9b4

Please sign in to comment.