ICU-199 eliminate unused code; coalesce methods

X-SVN-Rev: 651
This commit is contained in:
Alan Liu 2000-01-19 19:25:28 +00:00
parent 8387fe98df
commit 5304fb51e9
4 changed files with 11 additions and 293 deletions

View File

@ -185,41 +185,6 @@ bool_t TransliterationRule::masks(const TransliterationRule& r2) const {
0 == r2.pattern.compare(left2 - left, len, pattern); 0 == r2.pattern.compare(left2 - left, len, pattern);
} }
/**
* Return true if this rule matches the given text. The text being matched
* occupies a virtual buffer consisting of the contents of
* <code>result</code> concatenated to a substring of <code>text</code>.
* The substring is specified by <code>start</code> and <code>limit</code>.
* The value of <code>cursor</code> is an index into this virtual buffer,
* from 0 to the length of the buffer. In terms of the parameters,
* <code>cursor</code> must be between 0 and <code>result.length() + limit -
* start</code>.
* @param text the untranslated text
* @param start the beginning index, inclusive; <code>0 <= start
* <= limit</code>.
* @param limit the ending index, exclusive; <code>start <= limit
* <= text.length()</code>.
* @param result translated text so far
* @param cursor position at which to translate next, an offset into result.
* If greater than or equal to result.length(), represents offset start +
* cursor - result.length() into text.
* @param filter the filter. Any character for which
* <tt>filter.contains()</tt> returns <tt>false</tt> will not be
* altered by this transliterator. If <tt>filter</tt> is
* <tt>null</tt> then no filtering is applied.
*/
bool_t TransliterationRule::matches(const UnicodeString& text,
int32_t start, int32_t limit,
const UnicodeString& result,
int32_t cursor,
const TransliterationRuleData& data,
const UnicodeFilter* filter) const {
// Match anteContext, key, and postContext
return regionMatches(text, start, limit, result,
cursor - anteContextLength,
pattern, data, filter);
}
/** /**
* Return true if this rule matches the given text. * Return true if this rule matches the given text.
* @param text the text, both translated and untranslated * @param text the text, both translated and untranslated
@ -241,9 +206,17 @@ bool_t TransliterationRule::matches(const Replaceable& text,
const TransliterationRuleData& data, const TransliterationRuleData& data,
const UnicodeFilter* filter) const { const UnicodeFilter* filter) const {
// Match anteContext, key, and postContext // Match anteContext, key, and postContext
return regionMatches(text, start, limit, cursor -= anteContextLength;
cursor - anteContextLength, if (cursor < start || (cursor + pattern.length()) > limit) {
pattern, data, filter); return FALSE;
}
for (int32_t i=0; i<pattern.length(); ++i, ++cursor) {
if (!charMatches(pattern.charAt(i), text.charAt(cursor),
data, filter)) {
return FALSE;
}
}
return TRUE;
} }
/** /**
@ -282,92 +255,6 @@ int32_t TransliterationRule::getMatchDegree(const Replaceable& text,
(len < pattern.length() ? PARTIAL_MATCH : FULL_MATCH); (len < pattern.length() ? PARTIAL_MATCH : FULL_MATCH);
} }
/**
* Return true if a template matches the text. The entire length of the
* template is compared to the text at the cursor. As in
* <code>matches()</code>, the text being matched occupies a virtual buffer
* consisting of the contents of <code>result</code> concatenated to a
* substring of <code>text</code>. See <code>matches()</code> for details.
* @param text the untranslated text
* @param start the beginning index, inclusive; <code>0 <= start
* <= limit</code>.
* @param limit the ending index, exclusive; <code>start <= limit
* <= text.length()</code>.
* @param result translated text so far
* @param cursor position at which to translate next, an offset into result.
* If greater than or equal to result.length(), represents offset start +
* cursor - result.length() into text.
* @param templ the text to match against. All characters must match.
* @param data a dictionary of variables mapping <code>Character</code>
* to <code>UnicodeSet</code>
* @param filter the filter. Any character for which
* <tt>filter.contains()</tt> returns <tt>false</tt> will not be
* altered by this transliterator. If <tt>filter</tt> is
* <tt>null</tt> then no filtering is applied.
* @return true if there is a match
*/
bool_t TransliterationRule::regionMatches(const UnicodeString& text,
int32_t start, int32_t limit,
const UnicodeString& result,
int32_t cursor,
const UnicodeString& templ,
const TransliterationRuleData& data,
const UnicodeFilter* filter) const {
int32_t rlen = result.length();
if (cursor < 0
|| (cursor + templ.length()) > (rlen + limit - start)) {
return FALSE;
}
for (int32_t i=0; i<templ.length(); ++i, ++cursor) {
if (!charMatches(templ.charAt(i),
cursor < rlen ? result.charAt(cursor)
: text.charAt(cursor - rlen + start),
data, filter)) {
return FALSE;
}
}
return TRUE;
}
/**
* Return true if a template matches the text. The entire length of the
* template is compared to the text at the cursor.
* @param text the text, both translated and untranslated
* @param start the beginning index, inclusive; <code>0 <= start
* <= limit</code>.
* @param limit the ending index, exclusive; <code>start <= limit
* <= text.length()</code>.
* @param cursor position at which to translate next, representing offset
* into text. This value must be between <code>start</code> and
* <code>limit</code>.
* @param templ the text to match against. All characters must match.
* @param data a dictionary of variables mapping <code>Character</code>
* to <code>UnicodeSet</code>
* @param filter the filter. Any character for which
* <tt>filter.contains()</tt> returns <tt>false</tt> will not be
* altered by this transliterator. If <tt>filter</tt> is
* <tt>null</tt> then no filtering is applied.
* @return true if there is a match
*/
bool_t TransliterationRule::regionMatches(const Replaceable& text,
int32_t start, int32_t limit,
int32_t cursor,
const UnicodeString& templ,
const TransliterationRuleData& data,
const UnicodeFilter* filter) const {
if (cursor < start
|| (cursor + templ.length()) > limit) {
return FALSE;
}
for (int32_t i=0; i<templ.length(); ++i, ++cursor) {
if (!charMatches(templ.charAt(i), text.charAt(cursor),
data, filter)) {
return FALSE;
}
}
return TRUE;
}
/** /**
* Return the number of characters of the text that match this rule. If * Return the number of characters of the text that match this rule. If
* there is a mismatch, return -1. If the text is not long enough to match * there is a mismatch, return -1. If the text is not long enough to match

View File

@ -191,36 +191,6 @@ public:
*/ */
virtual bool_t masks(const TransliterationRule& r2) const; virtual bool_t masks(const TransliterationRule& r2) const;
/**
* Return true if this rule matches the given text. The text being matched
* occupies a virtual buffer consisting of the contents of
* <code>result</code> concatenated to a substring of <code>text</code>.
* The substring is specified by <code>start</code> and <code>limit</code>.
* The value of <code>cursor</code> is an index into this virtual buffer,
* from 0 to the length of the buffer. In terms of the parameters,
* <code>cursor</code> must be between 0 and <code>result.length() + limit -
* start</code>.
* @param text the untranslated text
* @param start the beginning index, inclusive; <code>0 <= start
* <= limit</code>.
* @param limit the ending index, exclusive; <code>start <= limit
* <= text.length()</code>.
* @param result translated text so far
* @param cursor position at which to translate next, an offset into result.
* If greater than or equal to result.length(), represents offset start +
* cursor - result.length() into text.
* @param filter the filter. Any character for which
* <tt>filter.isIn()</tt> returns <tt>false</tt> will not be
* altered by this transliterator. If <tt>filter</tt> is
* <tt>null</tt> then no filtering is applied.
*/
virtual bool_t matches(const UnicodeString& text,
int32_t start, int32_t limit,
const UnicodeString& result,
int32_t cursor,
const TransliterationRuleData& data,
const UnicodeFilter* filter) const;
/** /**
* Return true if this rule matches the given text. * Return true if this rule matches the given text.
* @param text the text, both translated and untranslated * @param text the text, both translated and untranslated
@ -273,65 +243,6 @@ public:
const TransliterationRuleData& data, const TransliterationRuleData& data,
const UnicodeFilter* filter) const; const UnicodeFilter* filter) const;
/**
* Return true if a template matches the text. The entire length of the
* template is compared to the text at the cursor. As in
* <code>matches()</code>, the text being matched occupies a virtual buffer
* consisting of the contents of <code>result</code> concatenated to a
* substring of <code>text</code>. See <code>matches()</code> for details.
* @param text the untranslated text
* @param start the beginning index, inclusive; <code>0 <= start
* <= limit</code>.
* @param limit the ending index, exclusive; <code>start <= limit
* <= text.length()</code>.
* @param result translated text so far
* @param cursor position at which to translate next, an offset into result.
* If greater than or equal to result.length(), represents offset start +
* cursor - result.length() into text.
* @param templ the text to match against. All characters must match.
* @param data a dictionary of variables mapping <code>Character</code>
* to <code>UnicodeSet</code>
* @param filter the filter. Any character for which
* <tt>filter.isIn()</tt> returns <tt>false</tt> will not be
* altered by this transliterator. If <tt>filter</tt> is
* <tt>null</tt> then no filtering is applied.
* @return true if there is a match
*/
virtual bool_t regionMatches(const UnicodeString& text,
int32_t start, int32_t limit,
const UnicodeString& result,
int32_t cursor,
const UnicodeString& templ,
const TransliterationRuleData& data,
const UnicodeFilter* filter) const;
/**
* Return true if a template matches the text. The entire length of the
* template is compared to the text at the cursor.
* @param text the text, both translated and untranslated
* @param start the beginning index, inclusive; <code>0 <= start
* <= limit</code>.
* @param limit the ending index, exclusive; <code>start <= limit
* <= text.length()</code>.
* @param cursor position at which to translate next, representing offset
* into text. This value must be between <code>start</code> and
* <code>limit</code>.
* @param templ the text to match against. All characters must match.
* @param data a dictionary of variables mapping <code>Character</code>
* to <code>UnicodeSet</code>
* @param filter the filter. Any character for which
* <tt>filter.isIn()</tt> returns <tt>false</tt> will not be
* altered by this transliterator. If <tt>filter</tt> is
* <tt>null</tt> then no filtering is applied.
* @return true if there is a match
*/
virtual bool_t regionMatches(const Replaceable& text,
int32_t start, int32_t limit,
int32_t cursor,
const UnicodeString& templ,
const TransliterationRuleData& data,
const UnicodeFilter* filter) const;
/** /**
* Return the number of characters of the text that match this rule. If * Return the number of characters of the text that match this rule. If
* there is a mismatch, return -1. If the text is not long enough to match * there is a mismatch, return -1. If the text is not long enough to match

View File

@ -183,53 +183,6 @@ void TransliterationRuleSet::freeze(const TransliterationRuleData& data,
//} //}
} }
/**
* Attempt to find a matching rule at the specified point in the text. The
* text being matched occupies a virtual buffer consisting of the contents
* of <code>result</code> concatenated to a substring of <code>text</code>.
* The substring is specified by <code>start</code> and <code>limit</code>.
* The value of <code>cursor</code> is an index into this virtual buffer,
* from 0 to the length of the buffer. In terms of the parameters,
* <code>cursor</code> must be between 0 and <code>result.length() + limit -
* start</code>.
* @param text the untranslated text
* @param start the beginning index, inclusive; <code>0 <= start
* <= limit</code>.
* @param limit the ending index, exclusive; <code>start <= limit
* <= text.length()</code>.
* @param result translated text
* @param cursor position at which to translate next, an offset into result.
* If greater than or equal to result.length(), represents offset start +
* cursor - result.length() into text.
* @param data a dictionary mapping variables to the sets they
* represent (maps <code>Character</code> to <code>UnicodeSet</code>)
* @param filter the filter. Any character for which
* <tt>filter.contains()</tt> returns <tt>false</tt> will not be
* altered by this transliterator. If <tt>filter</tt> is
* <tt>null</tt> then no filtering is applied.
* @return the matching rule, or null if none found.
*/
TransliterationRule*
TransliterationRuleSet::findMatch(const UnicodeString& text,
int32_t start, int32_t limit,
const UnicodeString& result,
int32_t cursor,
const TransliterationRuleData& data,
const UnicodeFilter* filter) const {
/* We only need to check our indexed bin of the rule table,
* based on the low byte of the first key character.
*/
int32_t rlen = result.length();
int16_t x = 0xFF & (cursor < rlen ? result.charAt(cursor)
: text.charAt(cursor - rlen + start));
for (int32_t i=index[x]; i<index[x+1]; ++i) {
if (rules[i]->matches(text, start, limit, result, cursor, data, filter)) {
return rules[i];
}
}
return NULL;
}
/** /**
* Attempt to find a matching rule at the specified point in the text. * Attempt to find a matching rule at the specified point in the text.
* @param text the text, both translated and untranslated * @param text the text, both translated and untranslated

View File

@ -91,39 +91,6 @@ public:
virtual void freeze(const TransliterationRuleData& data, virtual void freeze(const TransliterationRuleData& data,
UErrorCode& status); UErrorCode& status);
/**
* Attempt to find a matching rule at the specified point in the text. The
* text being matched occupies a virtual buffer consisting of the contents
* of <code>result</code> concatenated to a substring of <code>text</code>.
* The substring is specified by <code>start</code> and <code>limit</code>.
* The value of <code>cursor</code> is an index into this virtual buffer,
* from 0 to the length of the buffer. In terms of the parameters,
* <code>cursor</code> must be between 0 and <code>result.length() + limit -
* start</code>.
* @param text the untranslated text
* @param start the beginning index, inclusive; <code>0 <= start
* <= limit</code>.
* @param limit the ending index, exclusive; <code>start <= limit
* <= text.length()</code>.
* @param result tranlated text
* @param cursor position at which to translate next, an offset into result.
* If greater than or equal to result.length(), represents offset start +
* cursor - result.length() into text.
* @param data a dictionary mapping variables to the sets they
* represent (maps <code>Character</code> to <code>UnicodeSet</code>)
* @param filter the filter. Any character for which
* <tt>filter.isIn()</tt> returns <tt>false</tt> will not be
* altered by this transliterator. If <tt>filter</tt> is
* <tt>null</tt> then no filtering is applied.
* @return the matching rule, or null if none found.
*/
virtual TransliterationRule* findMatch(const UnicodeString& text,
int32_t start, int32_t limit,
const UnicodeString& result,
int32_t cursor,
const TransliterationRuleData& data,
const UnicodeFilter* filter) const;
/** /**
* Attempt to find a matching rule at the specified point in the text. * Attempt to find a matching rule at the specified point in the text.
* @param text the text, both translated and untranslated * @param text the text, both translated and untranslated