mirror of
https://github.com/google/brotli.git
synced 2024-11-21 19:20:09 +00:00
Update the dictionary and the transforms.
This commit is contained in:
parent
e7650080a8
commit
347781947a
4527
brotlispec.txt
4527
brotlispec.txt
File diff suppressed because it is too large
Load Diff
@ -987,7 +987,8 @@ int BrotliDecompress(BrotliInput input, BrotliOutput output) {
|
|||||||
copy_dst = &ringbuffer[pos & ringbuffer_mask];
|
copy_dst = &ringbuffer[pos & ringbuffer_mask];
|
||||||
|
|
||||||
if (distance > max_distance) {
|
if (distance > max_distance) {
|
||||||
if (copy_length >= 3 && copy_length <= kMaxDictionaryWordLength) {
|
if (copy_length >= kMinDictionaryWordLength &&
|
||||||
|
copy_length <= kMaxDictionaryWordLength) {
|
||||||
int offset = kBrotliDictionaryOffsetsByLength[copy_length];
|
int offset = kBrotliDictionaryOffsetsByLength[copy_length];
|
||||||
int word_id = distance - max_distance - 1;
|
int word_id = distance - max_distance - 1;
|
||||||
int shift = kBrotliDictionarySizeBitsByLength[copy_length];
|
int shift = kBrotliDictionarySizeBitsByLength[copy_length];
|
||||||
|
14384
dec/dictionary.h
14384
dec/dictionary.h
File diff suppressed because it is too large
Load Diff
257
dec/transform.h
257
dec/transform.h
@ -28,17 +28,26 @@ extern "C" {
|
|||||||
|
|
||||||
enum WordTransformType {
|
enum WordTransformType {
|
||||||
kIdentity = 0,
|
kIdentity = 0,
|
||||||
kOmit1 = 1,
|
kOmitLast1 = 1,
|
||||||
kOmit2 = 2,
|
kOmitLast2 = 2,
|
||||||
kOmit3 = 3,
|
kOmitLast3 = 3,
|
||||||
kOmit4 = 4,
|
kOmitLast4 = 4,
|
||||||
kOmit5 = 5,
|
kOmitLast5 = 5,
|
||||||
kOmit6 = 6,
|
kOmitLast6 = 6,
|
||||||
kOmit7 = 7,
|
kOmitLast7 = 7,
|
||||||
kOmit8 = 8,
|
kOmitLast8 = 8,
|
||||||
kOmit9 = 9,
|
kOmitLast9 = 9,
|
||||||
kUppercaseFirst = 10,
|
kUppercaseFirst = 10,
|
||||||
kUppercaseAll = 11
|
kUppercaseAll = 11,
|
||||||
|
kOmitFirst1 = 12,
|
||||||
|
kOmitFirst2 = 13,
|
||||||
|
kOmitFirst3 = 14,
|
||||||
|
kOmitFirst4 = 15,
|
||||||
|
kOmitFirst5 = 16,
|
||||||
|
kOmitFirst6 = 17,
|
||||||
|
kOmitFirst7 = 18,
|
||||||
|
kOmitFirst8 = 19,
|
||||||
|
kOmitFirst9 = 20
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -48,105 +57,127 @@ typedef struct {
|
|||||||
} Transform;
|
} Transform;
|
||||||
|
|
||||||
static const Transform kTransforms[] = {
|
static const Transform kTransforms[] = {
|
||||||
{ "", kIdentity, "" },
|
{ "", kIdentity, "" },
|
||||||
{ "", kIdentity, " ", },
|
{ "", kIdentity, " " },
|
||||||
{ "", kIdentity, "\">" },
|
{ " ", kIdentity, " " },
|
||||||
{ "", kUppercaseFirst, "" },
|
{ "", kOmitFirst1, "" },
|
||||||
{ "", kIdentity, "\"" },
|
{ "", kUppercaseFirst, " " },
|
||||||
{ "", kIdentity, ".", },
|
{ "", kIdentity, " the " },
|
||||||
{ "", kIdentity, "=\"" },
|
{ " ", kIdentity, "" },
|
||||||
{ "", kUppercaseFirst, " ", },
|
{ "s ", kIdentity, " " },
|
||||||
{ " ", kIdentity, "=\"" },
|
{ "", kIdentity, " of " },
|
||||||
{ " ", kIdentity, " ", },
|
{ "", kUppercaseFirst, "" },
|
||||||
{ "", kIdentity, ":", },
|
{ "", kIdentity, " and " },
|
||||||
{ " ", kIdentity, "" },
|
{ "", kOmitFirst2, "" },
|
||||||
{ "", kIdentity, "\n" },
|
{ "", kOmitLast1, "" },
|
||||||
{ "", kIdentity, "(", },
|
{ ", ", kIdentity, " " },
|
||||||
{ "", kUppercaseAll, "" },
|
{ "", kIdentity, ", " },
|
||||||
{ ".", kIdentity, "(", },
|
{ " ", kUppercaseFirst, " " },
|
||||||
{ "", kIdentity, "'" },
|
{ "", kIdentity, " in " },
|
||||||
{ "", kUppercaseFirst, "\"" },
|
{ "", kIdentity, " to " },
|
||||||
{ " ", kUppercaseFirst, " ", },
|
{ "e ", kIdentity, " " },
|
||||||
{ "", kOmit3, "" },
|
{ "", kIdentity, "\"" },
|
||||||
{ "", kOmit4, "" },
|
{ "", kIdentity, "." },
|
||||||
{ ".", kIdentity, "" },
|
{ "", kIdentity, "\">" },
|
||||||
{ "", kOmit1, "" },
|
{ "", kIdentity, "\n" },
|
||||||
{ "", kOmit2, "" },
|
{ "", kOmitLast3, "" },
|
||||||
{ "", kUppercaseFirst, "\">" },
|
{ "", kIdentity, "]" },
|
||||||
{ "", kOmit5, "" },
|
{ "", kIdentity, " for " },
|
||||||
{ "", kUppercaseAll, " ", },
|
{ "", kOmitFirst3, "" },
|
||||||
{ " ", kUppercaseFirst, "" },
|
{ "", kOmitLast2, "" },
|
||||||
{ "", kIdentity, ", ", },
|
{ "", kIdentity, " a " },
|
||||||
{ "", kUppercaseFirst, "(", },
|
{ "", kIdentity, " that " },
|
||||||
{ "", kIdentity, "\n\t" },
|
{ " ", kUppercaseFirst, "" },
|
||||||
{ "", kUppercaseFirst, "'" },
|
{ "", kIdentity, ". " },
|
||||||
{ ".", kIdentity, " ", },
|
{ ".", kIdentity, "" },
|
||||||
{ " ", kUppercaseAll, " ", },
|
{ " ", kIdentity, ", " },
|
||||||
{ "", kIdentity, "='" },
|
{ "", kOmitFirst4, "" },
|
||||||
{ "", kUppercaseFirst, ".", },
|
{ "", kIdentity, " with " },
|
||||||
{ " ", kIdentity, ".", },
|
{ "", kIdentity, "'" },
|
||||||
{ " ", kIdentity, ", ", },
|
{ "", kIdentity, " from " },
|
||||||
{ " ", kUppercaseAll, "" },
|
{ "", kIdentity, " by " },
|
||||||
{ "", kOmit6, "" },
|
{ "", kOmitFirst5, "" },
|
||||||
{ "", kOmit9, "" },
|
{ "", kOmitFirst6, "" },
|
||||||
{ "", kUppercaseAll, "\"" },
|
{ " the ", kIdentity, "" },
|
||||||
{ "", kIdentity, " the " },
|
{ "", kOmitLast4, "" },
|
||||||
{ "", kIdentity, " in " },
|
{ "", kIdentity, ". The " },
|
||||||
{ "", kIdentity, " of " },
|
{ "", kUppercaseAll, "" },
|
||||||
{ "", kIdentity, " to " },
|
{ "", kIdentity, " on " },
|
||||||
{ "", kIdentity, " and " },
|
{ "", kIdentity, " as " },
|
||||||
{ "", kIdentity, " is " },
|
{ "", kIdentity, " is " },
|
||||||
{ "", kIdentity, " on " },
|
{ "", kOmitLast7, "" },
|
||||||
{ "", kIdentity, " by " },
|
{ "", kOmitLast1, "ing " },
|
||||||
{ "", kIdentity, " for " },
|
{ "", kIdentity, "\n\t" },
|
||||||
{ "", kIdentity, " with " },
|
{ "", kIdentity, ":" },
|
||||||
{ "", kIdentity, " from " },
|
{ " ", kIdentity, ". " },
|
||||||
{ "", kIdentity, " as " },
|
{ "", kIdentity, "ed " },
|
||||||
{ "", kIdentity, " at " },
|
{ "", kOmitFirst9, "" },
|
||||||
{ "", kIdentity, "er " },
|
{ "", kOmitFirst7, "" },
|
||||||
{ " ", kIdentity, "='" },
|
{ "", kOmitLast6, "" },
|
||||||
{ "", kIdentity, " a " },
|
{ "", kIdentity, "(" },
|
||||||
{ "", kOmit7, "" },
|
{ "", kUppercaseFirst, ", " },
|
||||||
{ "", kOmit8, "" },
|
{ "", kOmitLast8, "" },
|
||||||
{ " ", kIdentity, "(", },
|
{ "", kIdentity, " at " },
|
||||||
{ " ", kIdentity, ". ", },
|
{ "", kIdentity, "ly " },
|
||||||
{ "", kIdentity, ". ", },
|
{ " the ", kIdentity, " of " },
|
||||||
{ "", kIdentity, ",", },
|
{ "", kOmitLast5, "" },
|
||||||
{ "", kOmit1, "ing " },
|
{ "", kOmitLast9, "" },
|
||||||
{ "", kIdentity, "ed " },
|
{ " ", kUppercaseFirst, ", " },
|
||||||
{ "", kUppercaseFirst, ", ", },
|
{ "", kUppercaseFirst, "\"" },
|
||||||
{ "", kUppercaseAll, ".", },
|
{ ".", kIdentity, "(" },
|
||||||
{ "", kUppercaseAll, "=\"" },
|
{ "", kUppercaseAll, " " },
|
||||||
{ "", kUppercaseAll, ", ", },
|
{ "", kUppercaseFirst, "\">" },
|
||||||
{ "", kUppercaseAll, "\">" },
|
{ "", kIdentity, "=\"" },
|
||||||
{ " ", kUppercaseFirst, ".", },
|
{ " ", kIdentity, "." },
|
||||||
{ " ", kUppercaseAll, "=\"" },
|
{ ".com/", kIdentity, "" },
|
||||||
{ " ", kUppercaseFirst, ", ", },
|
{ " the ", kIdentity, " of the " },
|
||||||
{ "", kUppercaseAll, "'" },
|
{ "", kUppercaseFirst, "'" },
|
||||||
{ "", kUppercaseFirst, "=\"" },
|
{ "", kIdentity, ". This " },
|
||||||
{ " ", kIdentity, ",", },
|
{ "", kIdentity, "," },
|
||||||
{ "", kIdentity, " that " },
|
{ ".", kIdentity, " " },
|
||||||
{ "", kUppercaseFirst, "='" },
|
{ "", kUppercaseFirst, "(" },
|
||||||
{ "", kUppercaseFirst, ". ", },
|
{ "", kUppercaseFirst, "." },
|
||||||
{ "", kUppercaseFirst, ",", },
|
{ "", kIdentity, " not " },
|
||||||
{ "", kIdentity, ". The " },
|
{ " ", kIdentity, "=\"" },
|
||||||
{ "\xc2\xa0", kIdentity, "" },
|
{ "", kIdentity, "er " },
|
||||||
{ " ", kUppercaseFirst, ". ", },
|
{ " ", kUppercaseAll, " " },
|
||||||
{ "", kUppercaseAll, ",", },
|
{ "", kIdentity, "al " },
|
||||||
{ "", kUppercaseAll, "(", },
|
{ " ", kUppercaseAll, "" },
|
||||||
{ " ", kUppercaseAll, "='" },
|
{ "", kIdentity, "='" },
|
||||||
{ "", kIdentity, "]" },
|
{ "", kUppercaseAll, "\"" },
|
||||||
{ "", kUppercaseAll, "='" },
|
{ "", kUppercaseFirst, ". " },
|
||||||
{ " ", kUppercaseAll, ".", },
|
{ " ", kIdentity, "(" },
|
||||||
{ "", kUppercaseAll, ". ", },
|
{ "", kIdentity, "ful " },
|
||||||
{ " ", kUppercaseFirst, "=\"" },
|
{ " ", kUppercaseFirst, ". " },
|
||||||
{ " ", kUppercaseAll, ". ", },
|
{ "", kIdentity, "ive " },
|
||||||
{ " ", kUppercaseFirst, ",", },
|
{ "", kIdentity, "less " },
|
||||||
{ " ", kUppercaseAll, ", ", },
|
{ "", kUppercaseAll, "'" },
|
||||||
{ "", kIdentity, "ize " },
|
{ "", kIdentity, "est " },
|
||||||
{ " ", kUppercaseFirst, "='" },
|
{ " ", kUppercaseFirst, "." },
|
||||||
{ "", kIdentity, "est " },
|
{ "", kUppercaseAll, "\">" },
|
||||||
{ "", kIdentity, ". This " },
|
{ " ", kIdentity, "='" },
|
||||||
|
{ "", kUppercaseFirst, "," },
|
||||||
|
{ "", kIdentity, "ize " },
|
||||||
|
{ "", kUppercaseAll, "." },
|
||||||
|
{ "\xc2\xa0", kIdentity, "" },
|
||||||
|
{ " ", kIdentity, "," },
|
||||||
|
{ "", kUppercaseFirst, "=\"" },
|
||||||
|
{ "", kUppercaseAll, "=\"" },
|
||||||
|
{ "", kIdentity, "ous " },
|
||||||
|
{ "", kUppercaseAll, ", " },
|
||||||
|
{ "", kUppercaseFirst, "='" },
|
||||||
|
{ " ", kUppercaseFirst, "," },
|
||||||
|
{ " ", kUppercaseAll, "=\"" },
|
||||||
|
{ " ", kUppercaseAll, ", " },
|
||||||
|
{ "", kUppercaseAll, "," },
|
||||||
|
{ "", kUppercaseAll, "(" },
|
||||||
|
{ "", kUppercaseAll, ". " },
|
||||||
|
{ " ", kUppercaseAll, "." },
|
||||||
|
{ "", kUppercaseAll, "='" },
|
||||||
|
{ " ", kUppercaseAll, ". " },
|
||||||
|
{ " ", kUppercaseFirst, "=\"" },
|
||||||
|
{ " ", kUppercaseAll, "='" },
|
||||||
|
{ " ", kUppercaseFirst, "='" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int kNumTransforms = sizeof(kTransforms) / sizeof(kTransforms[0]);
|
static const int kNumTransforms = sizeof(kTransforms) / sizeof(kTransforms[0]);
|
||||||
@ -173,11 +204,17 @@ static BROTLI_INLINE int TransformDictionaryWord(
|
|||||||
const char* prefix = kTransforms[transform].prefix;
|
const char* prefix = kTransforms[transform].prefix;
|
||||||
const char* suffix = kTransforms[transform].suffix;
|
const char* suffix = kTransforms[transform].suffix;
|
||||||
const int t = kTransforms[transform].transform;
|
const int t = kTransforms[transform].transform;
|
||||||
|
int skip = t < kOmitFirst1 ? 0 : t - (kOmitFirst1 - 1);
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
uint8_t* uppercase;
|
uint8_t* uppercase;
|
||||||
|
if (skip > len) {
|
||||||
|
skip = len;
|
||||||
|
}
|
||||||
while (*prefix) { dst[idx++] = (uint8_t)*prefix++; }
|
while (*prefix) { dst[idx++] = (uint8_t)*prefix++; }
|
||||||
if (t <= kOmit9) {
|
word += skip;
|
||||||
|
len -= skip;
|
||||||
|
if (t <= kOmitLast9) {
|
||||||
len -= t;
|
len -= t;
|
||||||
}
|
}
|
||||||
while (i < len) { dst[idx++] = word[i++]; }
|
while (i < len) { dst[idx++] = word[i++]; }
|
||||||
|
14384
enc/dictionary.h
14384
enc/dictionary.h
File diff suppressed because it is too large
Load Diff
@ -909,12 +909,13 @@ void BrotliCompressor::StoreDictionaryWordHashes() {
|
|||||||
if (static_dictionary_ == NULL) {
|
if (static_dictionary_ == NULL) {
|
||||||
static_dictionary_ = new StaticDictionary;
|
static_dictionary_ = new StaticDictionary;
|
||||||
for (int t = num_transforms - 1; t >= 0; --t) {
|
for (int t = num_transforms - 1; t >= 0; --t) {
|
||||||
for (int i = kMaxDictionaryWordLength; i >= 3; --i) {
|
for (int i = kMaxDictionaryWordLength;
|
||||||
|
i >= kMinDictionaryWordLength; --i) {
|
||||||
const int num_words = 1 << kBrotliDictionarySizeBitsByLength[i];
|
const int num_words = 1 << kBrotliDictionarySizeBitsByLength[i];
|
||||||
for (int j = num_words - 1; j >= 0; --j) {
|
for (int j = num_words - 1; j >= 0; --j) {
|
||||||
int word_id = t * num_words + j;
|
int word_id = t * num_words + j;
|
||||||
std::string word = GetTransformedDictionaryWord(i, word_id);
|
std::string word = GetTransformedDictionaryWord(i, word_id);
|
||||||
if (word.size() >= 3) {
|
if (word.size() >= 4) {
|
||||||
static_dictionary_->Insert(word, i, word_id);
|
static_dictionary_->Insert(word, i, word_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ class HashLongestMatch {
|
|||||||
literal_cost[(cur_ix + 1) & ring_buffer_mask] + 1.2;
|
literal_cost[(cur_ix + 1) & ring_buffer_mask] + 1.2;
|
||||||
bool match_found = false;
|
bool match_found = false;
|
||||||
// Don't accept a short copy from far away.
|
// Don't accept a short copy from far away.
|
||||||
double best_score = 8.11;
|
double best_score = 8.115;
|
||||||
if (insert_length_ < 4) {
|
if (insert_length_ < 4) {
|
||||||
double cost_diff[4] = { 0.10, 0.04, 0.02, 0.01 };
|
double cost_diff[4] = { 0.10, 0.04, 0.02, 0.01 };
|
||||||
best_score += cost_diff[insert_length_];
|
best_score += cost_diff[insert_length_];
|
||||||
|
@ -118,6 +118,13 @@ void EstimateBitCostsForLiteralsUTF8(size_t pos, size_t len, size_t mask,
|
|||||||
lit_cost *= 0.5;
|
lit_cost *= 0.5;
|
||||||
lit_cost += 0.5;
|
lit_cost += 0.5;
|
||||||
}
|
}
|
||||||
|
// Make the first bytes more expensive -- seems to help, not sure why.
|
||||||
|
// Perhaps because the entropy source is changing its properties
|
||||||
|
// rapidly in the beginning of the file, perhaps because the beginning
|
||||||
|
// of the data is a statistical "anomaly".
|
||||||
|
if (i < 2000) {
|
||||||
|
lit_cost += 0.7 - ((2000 - i) / 2000.0 * 0.35);
|
||||||
|
}
|
||||||
cost[(pos + i) & cost_mask] = lit_cost;
|
cost[(pos + i) & cost_mask] = lit_cost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
274
enc/transform.h
274
enc/transform.h
@ -25,17 +25,26 @@ namespace brotli {
|
|||||||
|
|
||||||
enum WordTransformType {
|
enum WordTransformType {
|
||||||
kIdentity = 0,
|
kIdentity = 0,
|
||||||
kOmit1 = 1,
|
kOmitLast1 = 1,
|
||||||
kOmit2 = 2,
|
kOmitLast2 = 2,
|
||||||
kOmit3 = 3,
|
kOmitLast3 = 3,
|
||||||
kOmit4 = 4,
|
kOmitLast4 = 4,
|
||||||
kOmit5 = 5,
|
kOmitLast5 = 5,
|
||||||
kOmit6 = 6,
|
kOmitLast6 = 6,
|
||||||
kOmit7 = 7,
|
kOmitLast7 = 7,
|
||||||
kOmit8 = 8,
|
kOmitLast8 = 8,
|
||||||
kOmit9 = 9,
|
kOmitLast9 = 9,
|
||||||
kUppercaseFirst = 10,
|
kUppercaseFirst = 10,
|
||||||
kUppercaseAll = 11,
|
kUppercaseAll = 11,
|
||||||
|
kOmitFirst1 = 12,
|
||||||
|
kOmitFirst2 = 13,
|
||||||
|
kOmitFirst3 = 14,
|
||||||
|
kOmitFirst4 = 15,
|
||||||
|
kOmitFirst5 = 16,
|
||||||
|
kOmitFirst6 = 17,
|
||||||
|
kOmitFirst7 = 18,
|
||||||
|
kOmitFirst8 = 19,
|
||||||
|
kOmitFirst9 = 20,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Transform {
|
struct Transform {
|
||||||
@ -45,105 +54,127 @@ struct Transform {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const Transform kTransforms[] = {
|
static const Transform kTransforms[] = {
|
||||||
{ "", kIdentity, "" },
|
{ "", kIdentity, "" },
|
||||||
{ "", kIdentity, " ", },
|
{ "", kIdentity, " " },
|
||||||
{ "", kIdentity, "\">" },
|
{ " ", kIdentity, " " },
|
||||||
{ "", kUppercaseFirst, "" },
|
{ "", kOmitFirst1, "" },
|
||||||
{ "", kIdentity, "\"" },
|
{ "", kUppercaseFirst, " " },
|
||||||
{ "", kIdentity, ".", },
|
{ "", kIdentity, " the " },
|
||||||
{ "", kIdentity, "=\"" },
|
{ " ", kIdentity, "" },
|
||||||
{ "", kUppercaseFirst, " ", },
|
{ "s ", kIdentity, " " },
|
||||||
{ " ", kIdentity, "=\"" },
|
{ "", kIdentity, " of " },
|
||||||
{ " ", kIdentity, " ", },
|
{ "", kUppercaseFirst, "" },
|
||||||
{ "", kIdentity, ":", },
|
{ "", kIdentity, " and " },
|
||||||
{ " ", kIdentity, "" },
|
{ "", kOmitFirst2, "" },
|
||||||
{ "", kIdentity, "\n" },
|
{ "", kOmitLast1, "" },
|
||||||
{ "", kIdentity, "(", },
|
{ ", ", kIdentity, " " },
|
||||||
{ "", kUppercaseAll, "" },
|
{ "", kIdentity, ", " },
|
||||||
{ ".", kIdentity, "(", },
|
{ " ", kUppercaseFirst, " " },
|
||||||
{ "", kIdentity, "'" },
|
{ "", kIdentity, " in " },
|
||||||
{ "", kUppercaseFirst, "\"" },
|
{ "", kIdentity, " to " },
|
||||||
{ " ", kUppercaseFirst, " ", },
|
{ "e ", kIdentity, " " },
|
||||||
{ "", kOmit3, "" },
|
{ "", kIdentity, "\"" },
|
||||||
{ "", kOmit4, "" },
|
{ "", kIdentity, "." },
|
||||||
{ ".", kIdentity, "" },
|
{ "", kIdentity, "\">" },
|
||||||
{ "", kOmit1, "" },
|
{ "", kIdentity, "\n" },
|
||||||
{ "", kOmit2, "" },
|
{ "", kOmitLast3, "" },
|
||||||
{ "", kUppercaseFirst, "\">" },
|
{ "", kIdentity, "]" },
|
||||||
{ "", kOmit5, "" },
|
{ "", kIdentity, " for " },
|
||||||
{ "", kUppercaseAll, " ", },
|
{ "", kOmitFirst3, "" },
|
||||||
{ " ", kUppercaseFirst, "" },
|
{ "", kOmitLast2, "" },
|
||||||
{ "", kIdentity, ", ", },
|
{ "", kIdentity, " a " },
|
||||||
{ "", kUppercaseFirst, "(", },
|
{ "", kIdentity, " that " },
|
||||||
{ "", kIdentity, "\n\t" },
|
{ " ", kUppercaseFirst, "" },
|
||||||
{ "", kUppercaseFirst, "'" },
|
{ "", kIdentity, ". " },
|
||||||
{ ".", kIdentity, " ", },
|
{ ".", kIdentity, "" },
|
||||||
{ " ", kUppercaseAll, " ", },
|
{ " ", kIdentity, ", " },
|
||||||
{ "", kIdentity, "='" },
|
{ "", kOmitFirst4, "" },
|
||||||
{ "", kUppercaseFirst, ".", },
|
{ "", kIdentity, " with " },
|
||||||
{ " ", kIdentity, ".", },
|
{ "", kIdentity, "'" },
|
||||||
{ " ", kIdentity, ", ", },
|
{ "", kIdentity, " from " },
|
||||||
{ " ", kUppercaseAll, "" },
|
{ "", kIdentity, " by " },
|
||||||
{ "", kOmit6, "" },
|
{ "", kOmitFirst5, "" },
|
||||||
{ "", kOmit9, "" },
|
{ "", kOmitFirst6, "" },
|
||||||
{ "", kUppercaseAll, "\"" },
|
{ " the ", kIdentity, "" },
|
||||||
{ "", kIdentity, " the " },
|
{ "", kOmitLast4, "" },
|
||||||
{ "", kIdentity, " in " },
|
{ "", kIdentity, ". The " },
|
||||||
{ "", kIdentity, " of " },
|
{ "", kUppercaseAll, "" },
|
||||||
{ "", kIdentity, " to " },
|
{ "", kIdentity, " on " },
|
||||||
{ "", kIdentity, " and " },
|
{ "", kIdentity, " as " },
|
||||||
{ "", kIdentity, " is " },
|
{ "", kIdentity, " is " },
|
||||||
{ "", kIdentity, " on " },
|
{ "", kOmitLast7, "" },
|
||||||
{ "", kIdentity, " by " },
|
{ "", kOmitLast1, "ing " },
|
||||||
{ "", kIdentity, " for " },
|
{ "", kIdentity, "\n\t" },
|
||||||
{ "", kIdentity, " with " },
|
{ "", kIdentity, ":" },
|
||||||
{ "", kIdentity, " from " },
|
{ " ", kIdentity, ". " },
|
||||||
{ "", kIdentity, " as " },
|
{ "", kIdentity, "ed " },
|
||||||
{ "", kIdentity, " at " },
|
{ "", kOmitFirst9, "" },
|
||||||
{ "", kIdentity, "er " },
|
{ "", kOmitFirst7, "" },
|
||||||
{ " ", kIdentity, "='" },
|
{ "", kOmitLast6, "" },
|
||||||
{ "", kIdentity, " a " },
|
{ "", kIdentity, "(" },
|
||||||
{ "", kOmit7, "" },
|
{ "", kUppercaseFirst, ", " },
|
||||||
{ "", kOmit8, "" },
|
{ "", kOmitLast8, "" },
|
||||||
{ " ", kIdentity, "(", },
|
{ "", kIdentity, " at " },
|
||||||
{ " ", kIdentity, ". ", },
|
{ "", kIdentity, "ly " },
|
||||||
{ "", kIdentity, ". ", },
|
{ " the ", kIdentity, " of " },
|
||||||
{ "", kIdentity, ",", },
|
{ "", kOmitLast5, "" },
|
||||||
{ "", kOmit1, "ing " },
|
{ "", kOmitLast9, "" },
|
||||||
{ "", kIdentity, "ed " },
|
{ " ", kUppercaseFirst, ", " },
|
||||||
{ "", kUppercaseFirst, ", ", },
|
{ "", kUppercaseFirst, "\"" },
|
||||||
{ "", kUppercaseAll, ".", },
|
{ ".", kIdentity, "(" },
|
||||||
{ "", kUppercaseAll, "=\"" },
|
{ "", kUppercaseAll, " " },
|
||||||
{ "", kUppercaseAll, ", ", },
|
{ "", kUppercaseFirst, "\">" },
|
||||||
{ "", kUppercaseAll, "\">" },
|
{ "", kIdentity, "=\"" },
|
||||||
{ " ", kUppercaseFirst, ".", },
|
{ " ", kIdentity, "." },
|
||||||
{ " ", kUppercaseAll, "=\"" },
|
{ ".com/", kIdentity, "" },
|
||||||
{ " ", kUppercaseFirst, ", ", },
|
{ " the ", kIdentity, " of the " },
|
||||||
{ "", kUppercaseAll, "'" },
|
{ "", kUppercaseFirst, "'" },
|
||||||
{ "", kUppercaseFirst, "=\"" },
|
{ "", kIdentity, ". This " },
|
||||||
{ " ", kIdentity, ",", },
|
{ "", kIdentity, "," },
|
||||||
{ "", kIdentity, " that " },
|
{ ".", kIdentity, " " },
|
||||||
{ "", kUppercaseFirst, "='" },
|
{ "", kUppercaseFirst, "(" },
|
||||||
{ "", kUppercaseFirst, ". ", },
|
{ "", kUppercaseFirst, "." },
|
||||||
{ "", kUppercaseFirst, ",", },
|
{ "", kIdentity, " not " },
|
||||||
{ "", kIdentity, ". The " },
|
{ " ", kIdentity, "=\"" },
|
||||||
{ "\xc2\xa0", kIdentity, "" },
|
{ "", kIdentity, "er " },
|
||||||
{ " ", kUppercaseFirst, ". ", },
|
{ " ", kUppercaseAll, " " },
|
||||||
{ "", kUppercaseAll, ",", },
|
{ "", kIdentity, "al " },
|
||||||
{ "", kUppercaseAll, "(", },
|
{ " ", kUppercaseAll, "" },
|
||||||
{ " ", kUppercaseAll, "='" },
|
{ "", kIdentity, "='" },
|
||||||
{ "", kIdentity, "]" },
|
{ "", kUppercaseAll, "\"" },
|
||||||
{ "", kUppercaseAll, "='" },
|
{ "", kUppercaseFirst, ". " },
|
||||||
{ " ", kUppercaseAll, ".", },
|
{ " ", kIdentity, "(" },
|
||||||
{ "", kUppercaseAll, ". ", },
|
{ "", kIdentity, "ful " },
|
||||||
{ " ", kUppercaseFirst, "=\"" },
|
{ " ", kUppercaseFirst, ". " },
|
||||||
{ " ", kUppercaseAll, ". ", },
|
{ "", kIdentity, "ive " },
|
||||||
{ " ", kUppercaseFirst, ",", },
|
{ "", kIdentity, "less " },
|
||||||
{ " ", kUppercaseAll, ", ", },
|
{ "", kUppercaseAll, "'" },
|
||||||
{ "", kIdentity, "ize " },
|
{ "", kIdentity, "est " },
|
||||||
{ " ", kUppercaseFirst, "='" },
|
{ " ", kUppercaseFirst, "." },
|
||||||
{ "", kIdentity, "est " },
|
{ "", kUppercaseAll, "\">" },
|
||||||
{ "", kIdentity, ". This " },
|
{ " ", kIdentity, "='" },
|
||||||
|
{ "", kUppercaseFirst, "," },
|
||||||
|
{ "", kIdentity, "ize " },
|
||||||
|
{ "", kUppercaseAll, "." },
|
||||||
|
{ "\xc2\xa0", kIdentity, "" },
|
||||||
|
{ " ", kIdentity, "," },
|
||||||
|
{ "", kUppercaseFirst, "=\"" },
|
||||||
|
{ "", kUppercaseAll, "=\"" },
|
||||||
|
{ "", kIdentity, "ous " },
|
||||||
|
{ "", kUppercaseAll, ", " },
|
||||||
|
{ "", kUppercaseFirst, "='" },
|
||||||
|
{ " ", kUppercaseFirst, "," },
|
||||||
|
{ " ", kUppercaseAll, "=\"" },
|
||||||
|
{ " ", kUppercaseAll, ", " },
|
||||||
|
{ "", kUppercaseAll, "," },
|
||||||
|
{ "", kUppercaseAll, "(" },
|
||||||
|
{ "", kUppercaseAll, ". " },
|
||||||
|
{ " ", kUppercaseAll, "." },
|
||||||
|
{ "", kUppercaseAll, "='" },
|
||||||
|
{ " ", kUppercaseAll, ". " },
|
||||||
|
{ " ", kUppercaseFirst, "=\"" },
|
||||||
|
{ " ", kUppercaseAll, "='" },
|
||||||
|
{ " ", kUppercaseFirst, "='" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int kNumTransforms = sizeof(kTransforms) / sizeof(kTransforms[0]);
|
static const int kNumTransforms = sizeof(kTransforms) / sizeof(kTransforms[0]);
|
||||||
@ -169,19 +200,26 @@ static int ToUpperCase(uint8_t *p, int len) {
|
|||||||
inline std::string ApplyTransform(
|
inline std::string ApplyTransform(
|
||||||
const Transform& t, const uint8_t* word, int len) {
|
const Transform& t, const uint8_t* word, int len) {
|
||||||
std::string ret(t.prefix);
|
std::string ret(t.prefix);
|
||||||
if (t.word_transform <= kOmit9) {
|
if (t.word_transform <= kOmitLast9) {
|
||||||
len -= t.word_transform;
|
len -= t.word_transform;
|
||||||
}
|
}
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
ret += std::string(word, word + len);
|
if (t.word_transform >= kOmitFirst1) {
|
||||||
uint8_t *uppercase = reinterpret_cast<uint8_t*>(&ret[ret.size() - len]);
|
const int skip = t.word_transform - (kOmitFirst1 - 1);
|
||||||
if (t.word_transform == kUppercaseFirst) {
|
if (len > skip) {
|
||||||
ToUpperCase(uppercase, len);
|
ret += std::string(word + skip, word + len);
|
||||||
} else if (t.word_transform == kUppercaseAll) {
|
}
|
||||||
while (len > 0) {
|
} else {
|
||||||
int step = ToUpperCase(uppercase, len);
|
ret += std::string(word, word + len);
|
||||||
uppercase += step;
|
uint8_t *uppercase = reinterpret_cast<uint8_t*>(&ret[ret.size() - len]);
|
||||||
len -= step;
|
if (t.word_transform == kUppercaseFirst) {
|
||||||
|
ToUpperCase(uppercase, len);
|
||||||
|
} else if (t.word_transform == kUppercaseAll) {
|
||||||
|
while (len > 0) {
|
||||||
|
int step = ToUpperCase(uppercase, len);
|
||||||
|
uppercase += step;
|
||||||
|
len -= step;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user