mirror of https://github.com/odrling/Aegisub
Use std::binary_search rather than a set in GetWordBoundaries
This is slightly faster and simpler. Originally committed to SVN as r6612.
This commit is contained in:
parent
909a0ca280
commit
1f1e9a700a
|
@ -34,14 +34,9 @@
|
|||
/// @ingroup utility
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <set>
|
||||
|
||||
#ifdef __UNIX__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -169,9 +164,7 @@ void GetWordBoundaries(const wxString text, IntPairVector &results, int start, i
|
|||
if (end < 0) end = text.size();
|
||||
|
||||
// Delimiters
|
||||
static std::set<wxUniChar> delims;
|
||||
if (delims.empty()) {
|
||||
const wxUniChar delim_chars[] = {
|
||||
const wxUniChar delims[] = {
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0028,
|
||||
0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f, 0x003a,
|
||||
0x003b, 0x003d, 0x003f, 0x0040, 0x005b, 0x005c, 0x005d, 0x005e,
|
||||
|
@ -188,8 +181,6 @@ void GetWordBoundaries(const wxString text, IntPairVector &results, int start, i
|
|||
0x3019, 0x301a, 0x301b, 0x301c, 0x3030, 0x303d, 0x30fb, 0xff0a,
|
||||
0xff5b, 0xff5d, 0xff5e
|
||||
};
|
||||
delims.insert(delim_chars, delim_chars + sizeof(delim_chars) / sizeof(delim_chars[0]));
|
||||
}
|
||||
|
||||
for (int i = start; i < end + 1; ++i) {
|
||||
// Current character
|
||||
|
@ -227,7 +218,7 @@ void GetWordBoundaries(const wxString text, IntPairVector &results, int start, i
|
|||
i++;
|
||||
}
|
||||
// Check for standard delimiters
|
||||
else if (delims.count(cur)) {
|
||||
else if (std::binary_search(delims, delims + sizeof(delims) / sizeof(delims[0]), cur)) {
|
||||
if (start != i)
|
||||
results.push_back(std::make_pair(start, i));
|
||||
start = i + 1;
|
||||
|
|
Loading…
Reference in New Issue