[vte] Remove unused quark arguments all around the matcher code
- From: Behdad Esfahbod <behdad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] Remove unused quark arguments all around the matcher code
- Date: Thu, 22 May 2014 01:18:50 +0000 (UTC)
commit 9f22a3c9c5eaabf7c23c1db759e9749e37f4191d
Author: Behdad Esfahbod <behdad behdad org>
Date: Wed May 21 21:10:58 2014 -0400
Remove unused quark arguments all around the matcher code
src/matcher.c | 11 +++----
src/matcher.h | 6 ++--
src/table.c | 72 ++++++++++++++++++++++------------------------------
src/table.h | 4 +-
src/vte-private.h | 3 +-
src/vte.c | 5 ---
src/vteseq.c | 9 +++---
7 files changed, 46 insertions(+), 64 deletions(-)
---
diff --git a/src/matcher.c b/src/matcher.c
index 1bd40e4..c383b61 100644
--- a/src/matcher.c
+++ b/src/matcher.c
@@ -44,9 +44,9 @@ static struct _vte_matcher_impl dummy_vte_matcher_table = {
static void
_vte_matcher_add(const struct _vte_matcher *matcher,
const char *pattern, gssize length,
- const char *result, GQuark quark)
+ const char *result)
{
- matcher->impl->klass->add(matcher->impl, pattern, length, result, quark);
+ matcher->impl->klass->add(matcher->impl, pattern, length, result);
}
/* Loads all sequences into matcher */
@@ -61,8 +61,7 @@ _vte_matcher_init(struct _vte_matcher *matcher)
for (i = 0; _vte_xterm_capability_strings[i].value != NULL; i++) {
code = _vte_xterm_capability_strings[i].code;
value = _vte_xterm_capability_strings[i].value;
- _vte_matcher_add(matcher, code, strlen (code),
- value, 0);
+ _vte_matcher_add(matcher, code, strlen (code), value);
}
_VTE_DEBUG_IF(VTE_DEBUG_MATCHER) {
@@ -142,14 +141,14 @@ const char *
_vte_matcher_match(struct _vte_matcher *matcher,
const gunichar *pattern, gssize length,
const char **res, const gunichar **consumed,
- GQuark *quark, GValueArray **array)
+ GValueArray **array)
{
if (G_UNLIKELY (array != NULL && matcher->free_params != NULL)) {
*array = matcher->free_params;
matcher->free_params = NULL;
}
return matcher->match(matcher->impl, pattern, length,
- res, consumed, quark, array);
+ res, consumed, array);
}
/* Dump out the contents of a matcher, mainly for debugging. */
diff --git a/src/matcher.h b/src/matcher.h
index 2522c39..29f9909 100644
--- a/src/matcher.h
+++ b/src/matcher.h
@@ -37,10 +37,10 @@ typedef struct _vte_matcher_impl *(*_vte_matcher_create_func)(void);
typedef const char *(*_vte_matcher_match_func)(struct _vte_matcher_impl *impl,
const gunichar *pattern, gssize length,
const char **res, const gunichar **consumed,
- GQuark *quark, GValueArray **array);
+ GValueArray **array);
typedef void (*_vte_matcher_add_func)(struct _vte_matcher_impl *impl,
const char *pattern, gssize length,
- const char *result, GQuark quark);
+ const char *result);
typedef void (*_vte_matcher_print_func)(struct _vte_matcher_impl *impl);
typedef void (*_vte_matcher_destroy_func)(struct _vte_matcher_impl *impl);
struct _vte_matcher_class{
@@ -61,7 +61,7 @@ void _vte_matcher_free(struct _vte_matcher *matcher);
const char *_vte_matcher_match(struct _vte_matcher *matcher,
const gunichar *pattern, gssize length,
const char **res, const gunichar **consumed,
- GQuark *quark, GValueArray **array);
+ GValueArray **array);
/* Dump out the contents of a matcher, mainly for debugging. */
void _vte_matcher_print(struct _vte_matcher *matcher);
diff --git a/src/table.c b/src/table.c
index 75fad08..6485492 100644
--- a/src/table.c
+++ b/src/table.c
@@ -40,7 +40,6 @@
struct _vte_table {
struct _vte_matcher_impl impl;
- GQuark resultq;
const char *result;
unsigned char *original;
gssize original_length;
@@ -194,7 +193,7 @@ static void
_vte_table_addi(struct _vte_table *table,
const unsigned char *original, gssize original_length,
const char *pattern, gssize length,
- const char *result, GQuark quark, int inc)
+ const char *result, int inc)
{
int i;
guint8 check;
@@ -214,8 +213,7 @@ _vte_table_addi(struct _vte_table *table,
"`%s' and `%s' are indistinguishable.\n",
table->result, result);
- table->resultq = g_quark_from_string(result);
- table->result = g_quark_to_string(table->resultq);
+ table->result = g_intern_string(result);
if (table->original != NULL) {
g_free(table->original);
}
@@ -231,7 +229,7 @@ _vte_table_addi(struct _vte_table *table,
if (pattern[1] == 'i') {
_vte_table_addi(table, original, original_length,
pattern + 2, length - 2,
- result, quark, inc + 1);
+ result, inc + 1);
return;
}
@@ -249,7 +247,7 @@ _vte_table_addi(struct _vte_table *table,
/* Add the rest of the string to the subtable. */
_vte_table_addi(subtable, original, original_length,
pattern + 2, length - 2,
- result, quark, inc);
+ result, inc);
return;
}
@@ -273,7 +271,7 @@ _vte_table_addi(struct _vte_table *table,
_vte_table_addi(table, b->data, b->len,
(const char *)b->data + initial,
b->len - initial,
- result, quark, inc);
+ result, inc);
g_byte_array_free(b, TRUE);
}
/* Create a new subtable. */
@@ -286,7 +284,7 @@ _vte_table_addi(struct _vte_table *table,
/* Add the rest of the string to the subtable. */
_vte_table_addi(subtable, original, original_length,
pattern + 2, length - 2,
- result, quark, inc);
+ result, inc);
return;
}
@@ -304,7 +302,7 @@ _vte_table_addi(struct _vte_table *table,
/* Add the rest of the string to the subtable. */
_vte_table_addi(subtable, original, original_length,
pattern + 2, length - 2,
- result, quark, inc);
+ result, inc);
return;
}
@@ -325,7 +323,7 @@ _vte_table_addi(struct _vte_table *table,
/* Add the rest of the string to the subtable. */
_vte_table_addi(subtable, original, original_length,
pattern + 2, length - 2,
- result, quark, inc);
+ result, inc);
return;
}
@@ -352,7 +350,7 @@ _vte_table_addi(struct _vte_table *table,
_vte_table_addi(subtable,
original, original_length,
pattern + 3, length - 3,
- result, quark, inc);
+ result, inc);
}
/* Also add a subtable for higher characters. */
if (table->table == NULL) {
@@ -369,7 +367,7 @@ _vte_table_addi(struct _vte_table *table,
/* Add the rest of the string to the subtable. */
_vte_table_addi(subtable, original, original_length,
pattern + 3, length - 3,
- result, quark, inc);
+ result, inc);
return;
}
}
@@ -392,26 +390,26 @@ _vte_table_addi(struct _vte_table *table,
/* Add the rest of the string to the subtable. */
_vte_table_addi(subtable, original, original_length,
pattern + 1, length - 1,
- result, quark, inc);
+ result, inc);
}
/* Add a string to the matching tree. */
void
_vte_table_add(struct _vte_table *table,
const char *pattern, gssize length,
- const char *result, GQuark quark)
+ const char *result)
{
_vte_table_addi(table,
(const unsigned char *) pattern, length,
pattern, length,
- result, quark, 0);
+ result, 0);
}
/* Match a string in a subtree. */
static const char *
_vte_table_matchi(struct _vte_table *table,
const gunichar *candidate, gssize length,
- const char **res, const gunichar **consumed, GQuark *quark,
+ const char **res, const gunichar **consumed,
unsigned char **original, gssize *original_length,
struct _vte_table_arginfo_head *params)
{
@@ -425,7 +423,6 @@ _vte_table_matchi(struct _vte_table *table,
*original = table->original;
*original_length = table->original_length;
*res = table->result;
- *quark = table->resultq;
return table->result;
}
@@ -453,7 +450,7 @@ _vte_table_matchi(struct _vte_table *table,
arginfo->length = i;
/* Continue. */
return _vte_table_matchi(subtable, candidate + i, length - i,
- res, consumed, quark,
+ res, consumed,
original, original_length, params);
}
@@ -478,7 +475,7 @@ _vte_table_matchi(struct _vte_table *table,
/* Try and continue. */
local_result = _vte_table_matchi(subtable,
candidate + i, length - i,
- res, consumed, quark,
+ res, consumed,
original, original_length,
params);
if (local_result != NULL) {
@@ -506,7 +503,7 @@ _vte_table_matchi(struct _vte_table *table,
arginfo->length = i;
/* Continue. */
return _vte_table_matchi(subtable, candidate + i, length - i,
- res, consumed, quark,
+ res, consumed,
original, original_length, params);
}
@@ -521,7 +518,7 @@ _vte_table_matchi(struct _vte_table *table,
arginfo->length = 1;
/* Continue. */
return _vte_table_matchi(subtable, candidate + 1, length - 1,
- res, consumed, quark,
+ res, consumed,
original, original_length, params);
}
@@ -618,12 +615,11 @@ const char *
_vte_table_match(struct _vte_table *table,
const gunichar *candidate, gssize length,
const char **res, const gunichar **consumed,
- GQuark *quark, GValueArray **array)
+ GValueArray **array)
{
struct _vte_table *head;
const gunichar *dummy_consumed;
const char *dummy_res;
- GQuark dummy_quark;
GValueArray *dummy_array;
const char *ret;
unsigned char *original, *p;
@@ -642,10 +638,6 @@ _vte_table_match(struct _vte_table *table,
consumed = &dummy_consumed;
}
*consumed = candidate;
- if (G_UNLIKELY (quark == NULL)) {
- quark = &dummy_quark;
- }
- *quark = 0;
if (G_UNLIKELY (array == NULL)) {
dummy_array = NULL;
array = &dummy_array;
@@ -684,7 +676,6 @@ _vte_table_match(struct _vte_table *table,
/* Got a literal match. */
*consumed = candidate + i;
*res = head->result;
- *quark = head->resultq;
return *res;
}
@@ -692,7 +683,7 @@ _vte_table_match(struct _vte_table *table,
/* Check for a pattern match. */
ret = _vte_table_matchi(table, candidate, length,
- res, consumed, quark,
+ res, consumed,
&original, &original_length,
¶ms);
*res = ret;
@@ -916,20 +907,19 @@ main(int argc, char **argv)
const gunichar *consumed;
char *tmp;
gunichar *candidate;
- GQuark quark;
GValueArray *array;
g_type_init();
table = _vte_table_new();
- _vte_table_add(table, "ABCDEFG", 7, "ABCDEFG", 0);
- _vte_table_add(table, "ABCD", 4, "ABCD", 0);
- _vte_table_add(table, "ABCDEFH", 7, "ABCDEFH", 0);
- _vte_table_add(table, "ACDEFH", 6, "ACDEFH", 0);
- _vte_table_add(table, "ACDEF%sJ", 8, "ACDEF%sJ", 0);
- _vte_table_add(table, "ACDEF%i%mJ", 10, "ACDEF%dJ", 0);
- _vte_table_add(table, "[%mh", 5, "move-cursor", 0);
- _vte_table_add(table, "[%mm", 5, "character-attributes", 0);
- _vte_table_add(table, "]3;%s", 7, "set-icon-title", 0);
- _vte_table_add(table, "]4;%s", 7, "set-window-title", 0);
+ _vte_table_add(table, "ABCDEFG", 7, "ABCDEFG");
+ _vte_table_add(table, "ABCD", 4, "ABCD");
+ _vte_table_add(table, "ABCDEFH", 7, "ABCDEFH");
+ _vte_table_add(table, "ACDEFH", 6, "ACDEFH");
+ _vte_table_add(table, "ACDEF%sJ", 8, "ACDEF%sJ");
+ _vte_table_add(table, "ACDEF%i%mJ", 10, "ACDEF%dJ");
+ _vte_table_add(table, "[%mh", 5, "move-cursor");
+ _vte_table_add(table, "[%mm", 5, "character-attributes");
+ _vte_table_add(table, "]3;%s", 7, "set-icon-title");
+ _vte_table_add(table, "]4;%s", 7, "set-window-title");
printf("Table contents:\n");
_vte_table_print(table);
printf("\nTable matches:\n");
@@ -938,7 +928,7 @@ main(int argc, char **argv)
candidate = make_wide(p);
array = NULL;
_vte_table_match(table, candidate, strlen(p),
- &result, &consumed, &quark, &array);
+ &result, &consumed, &array);
tmp = escape(p);
printf("`%s' => `%s'", tmp, (result ? result : "(NULL)"));
g_free(tmp);
diff --git a/src/table.h b/src/table.h
index c96a277..a909d52 100644
--- a/src/table.h
+++ b/src/table.h
@@ -37,13 +37,13 @@ void _vte_table_free(struct _vte_table *table);
/* Add a string to the matching tree. */
void _vte_table_add(struct _vte_table *table,
const char *pattern, gssize length,
- const char *result, GQuark quark);
+ const char *result);
/* Check if a string matches something in the tree. */
const char *_vte_table_match(struct _vte_table *table,
const gunichar *pattern, gssize length,
const char **res, const gunichar **consumed,
- GQuark *quark, GValueArray **array);
+ GValueArray **array);
/* Dump out the contents of a tree. */
void _vte_table_print(struct _vte_table *table);
diff --git a/src/vte-private.h b/src/vte-private.h
index e3b1574..89afddb 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -450,8 +450,7 @@ void _vte_terminal_ring_remove (VteTerminal *terminal, glong position);
/* vteseq.c: */
void _vte_terminal_handle_sequence(VteTerminal *terminal,
- const char *match_s,
- GQuark match,
+ const char *match,
GValueArray *params);
gboolean _vte_terminal_xy_to_grid(VteTerminal *terminal,
diff --git a/src/vte.c b/src/vte.c
index 0890a6d..5df8e84 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -3727,7 +3727,6 @@ skip_chunk:
while (start < wcount && !leftovers) {
const char *match;
- GQuark quark;
const gunichar *next;
GValueArray *params = NULL;
@@ -3737,7 +3736,6 @@ skip_chunk:
wcount - start,
&match,
&next,
- &quark,
¶ms);
/* We're in one of three possible situations now.
* First, the match string is a non-empty string and next
@@ -3750,7 +3748,6 @@ skip_chunk:
* behavior. */
_vte_terminal_handle_sequence(terminal,
match,
- quark,
params);
/* Skip over the proper number of unicode chars. */
start = (next - wbuf);
@@ -3805,7 +3802,6 @@ skip_chunk:
(start + 1 < next - wbuf)) {
const gunichar *tnext = NULL;
const char *tmatch = NULL;
- GQuark tquark = 0;
gunichar ctrl;
int i;
/* We don't want to permute it if it's another
@@ -3815,7 +3811,6 @@ skip_chunk:
wcount - (next - wbuf),
&tmatch,
&tnext,
- &tquark,
NULL);
/* We only do this for non-control-sequence
* characters and random garbage. */
diff --git a/src/vteseq.c b/src/vteseq.c
index ebfee21..3eeb3a7 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -3109,17 +3109,16 @@ _vte_sequence_get_handler (const char *name)
/* Handle a terminal control sequence and its parameters. */
void
_vte_terminal_handle_sequence(VteTerminal *terminal,
- const char *match_s,
- GQuark match G_GNUC_UNUSED,
+ const char *match,
GValueArray *params)
{
VteTerminalSequenceHandler handler;
_VTE_DEBUG_IF(VTE_DEBUG_PARSE)
- display_control_sequence(match_s, params);
+ display_control_sequence(match, params);
/* Find the handler for this control sequence. */
- handler = _vte_sequence_get_handler (match_s);
+ handler = _vte_sequence_get_handler (match);
if (handler != NULL) {
/* Let the handler handle it. */
@@ -3127,6 +3126,6 @@ _vte_terminal_handle_sequence(VteTerminal *terminal,
} else {
_vte_debug_print (VTE_DEBUG_MISC,
"No handler for control sequence `%s' defined.\n",
- match_s);
+ match);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]