From 1e17b5f696dffeb9eac8f9f8c8562eb7842cd316 Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Sun, 6 Jan 2013 11:02:39 +0000 Subject: [PATCH] Cleaner transformation calls (one less size_t for agruments). We can coalesce it in correct_edit. --- correct.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/correct.c b/correct.c index 5be4f35..226579b 100644 --- a/correct.c +++ b/correct.c @@ -318,7 +318,7 @@ static const char correct_alpha[] = "abcdefghijklmnopqrstuvwxyz" * need to take a size_t ** to carry it along (would all the argument * overhead be worth it?) */ -static size_t correct_deletion(const char *ident, char **array, size_t index) { +static size_t correct_deletion(const char *ident, char **array) { size_t itr = 0; const size_t len = strlen(ident); @@ -326,13 +326,13 @@ static size_t correct_deletion(const char *ident, char **array, size_t index) { char *a = (char*)correct_pool_alloc(len+1); memcpy(a, ident, itr); memcpy(a + itr, ident + itr + 1, len - itr); - array[index + itr] = a; + array[itr] = a; } return itr; } -static size_t correct_transposition(const char *ident, char **array, size_t index) { +static size_t correct_transposition(const char *ident, char **array) { size_t itr = 0; const size_t len = strlen(ident); @@ -343,13 +343,13 @@ static size_t correct_transposition(const char *ident, char **array, size_t inde tmp = a[itr]; a[itr ] = a[itr+1]; a[itr+1] = tmp; - array[index + itr] = a; + array[itr] = a; } return itr; } -static size_t correct_alteration(const char *ident, char **array, size_t index) { +static size_t correct_alteration(const char *ident, char **array) { size_t itr = 0; size_t jtr = 0; size_t ktr = 0; @@ -360,14 +360,14 @@ static size_t correct_alteration(const char *ident, char **array, size_t index) char *a = (char*)correct_pool_alloc(len+1); memcpy(a, ident, len+1); a[itr] = correct_alpha[jtr]; - array[index + ktr] = a; + array[ktr] = a; } } return ktr; } -static size_t correct_insertion(const char *ident, char **array, size_t index) { +static size_t correct_insertion(const char *ident, char **array) { size_t itr = 0; size_t jtr = 0; size_t ktr = 0; @@ -379,7 +379,7 @@ static size_t correct_insertion(const char *ident, char **array, size_t index) { memcpy(a, ident, itr); memcpy(a + itr + 1, ident + itr, len - itr + 1); a[itr] = correct_alpha[jtr]; - array[index + ktr] = a; + array[ktr] = a; } } @@ -405,10 +405,10 @@ static char **correct_edit(const char *ident) { if (!find) return NULL; - next = correct_deletion (ident, find, 0); - next += correct_transposition(ident, find, next); - next += correct_alteration (ident, find, next); - /*****/ correct_insertion (ident, find, next); + next = correct_deletion (ident, find); + next += correct_transposition(ident, find+next); + next += correct_alteration (ident, find+next); + /*****/ correct_insertion (ident, find+next); return find; } -- 2.39.2