summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbehdad <behdad>2002-01-14 10:36:16 +0000
committerbehdad <behdad>2002-01-14 10:36:16 +0000
commitfe30fb1ce01167a377abe9da24468f4d95c62bf2 (patch)
tree8bfcb626ff6b2efd321176c96cbb79bf2a4f1475
parent6d645410b9f224fb81349de000a10c93b5eb9cec (diff)
Rewrote run_length_encode_types().
-rw-r--r--ChangeLog3
-rw-r--r--fribidi.c48
2 files changed, 20 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index fc11914..3da931d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2002-01-14 Behdad Esfahbod <behdad@bamdad.org>
+ * fribidi.c: Rewrote run_length_encode_types() main loop.
+
2002-01-12 Behdad Esfahbod <behdad@bamdad.org>
* fribidi.spec.in: Define RPM serial version as interface version.
* TODO: New tasks added.
diff --git a/fribidi.c b/fribidi.c
index b13a002..9144adb 100644
--- a/fribidi.c
+++ b/fribidi.c
@@ -167,11 +167,18 @@ free_type_link (TypeLink *link)
#endif
}
+#define FRIBIDI_ADD_TYPE_LINK(p,q) \
+ { \
+ (p)->len = (q)->pos - (p)->pos; \
+ (p)->next = (q); \
+ (q)->prev = (p); \
+ (p) = (q); \
+ }
+
static TypeLink *
run_length_encode_types (FriBidiCharType *char_type, FriBidiStrIndex type_len)
{
TypeLink *list, *last, *link;
- TypeLink current;
FriBidiStrIndex i;
@@ -179,45 +186,24 @@ run_length_encode_types (FriBidiCharType *char_type, FriBidiStrIndex type_len)
list = new_type_link ();
list->type = FRIBIDI_TYPE_SOT;
list->level = FRIBIDI_LEVEL_START;
- list->len = 0;
- list->pos = 0;
last = list;
/* Sweep over the string_type s */
- current.type = FRIBIDI_LEVEL_START;
- current.len = 0;
- current.pos = -1;
- for (i = 0; i <= type_len; i++)
- {
- if (i == type_len || char_type[i] != current.type)
- {
- if (current.pos >= 0)
- {
- link = new_type_link ();
- link->type = current.type;
- link->pos = current.pos;
- link->len = current.len;
- last->next = link;
- link->prev = last;
- last = last->next;
- }
- if (i == type_len)
- break;
- current.len = 0;
- current.pos = i;
- }
- current.type = char_type[i];
- current.len++;
- }
+ for (i = 0; i < type_len; i++)
+ if (char_type[i] != last->type)
+ {
+ link = new_type_link ();
+ link->type = char_type[i];
+ link->pos = i;
+ FRIBIDI_ADD_TYPE_LINK(last,link)
+ }
/* Add the ending link */
link = new_type_link ();
link->type = FRIBIDI_TYPE_EOT;
link->level = FRIBIDI_LEVEL_END;
- link->len = 0;
link->pos = type_len;
- last->next = link;
- link->prev = last;
+ FRIBIDI_ADD_TYPE_LINK(last,link);
return list;
}