Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: compiled/String.h

Issue 29425555: Issue 5201 - [emscripten] Replace EM_ASM calls by a custom JavaScript library (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created April 30, 2017, 6:54 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compiled/FilterNotifier.cpp ('k') | compiled/debug.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/String.h
===================================================================
--- a/compiled/String.h
+++ b/compiled/String.h
@@ -21,16 +21,23 @@
#include <cstddef>
#include <cstring>
#include <type_traits>
#include <emscripten.h>
#include "debug.h"
+extern "C"
+{
+ // It seems that calling JS is the easiest solution for lowercasing Unicode
+ // characters.
+ char16_t CharToLower(char16_t charCode);
+}
+
inline void String_assert_readonly(bool readOnly);
class String
{
friend class DependentString;
friend class OwnedString;
public:
@@ -183,21 +190,17 @@ public:
value_type currChar = mBuf[i];
// This should be more efficient with a lookup table but I couldn't measure
// any performance difference.
if (currChar >= u'A' && currChar <= u'Z')
mBuf[i] = currChar + u'a' - u'A';
else if (currChar >= 128)
{
- // It seems that calling JS is the easiest solution for lowercasing
- // Unicode characters.
- mBuf[i] = EM_ASM_INT({
- return String.fromCharCode($0).toLowerCase().charCodeAt(0);
- }, currChar);
+ mBuf[i] = CharToLower(currChar);
}
}
}
};
class DependentString : public String
{
public:
« no previous file with comments | « compiled/FilterNotifier.cpp ('k') | compiled/debug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld