Skip to content

Instantly share code, notes, and snippets.

@rctay
rctay / dulwich.sh
Created August 3, 2011 11:11
useful shell history
# dulwich - test commands
python setup.py test -s dulwich.tests
python setup.py test -s dulwich.tests.test_repository.RepositoryTests
# with nose - exclude compat
nosetests -e compat
@rctay
rctay / gist:1099515
Created July 22, 2011 14:07
[gsoc-diff] xdl_trim_head()
diff --git a/xdiff/xprepare.c b/xdiff/xprepare.c
index 82bff88..061ace9 100644
--- a/xdiff/xprepare.c
+++ b/xdiff/xprepare.c
@@ -55,7 +55,7 @@ static void xdl_free_classifier(xdlclassifier_t *cf);
static int xdl_classify_record(xdlclassifier_t *cf, xrecord_t **rhash, unsigned int hbits,
xrecord_t *rec);
static int xdl_prepare_ctx(mmfile_t *mf, long narec, xpparam_t const *xpp,
- xdlclassifier_t *cf, xdfile_t *xdf);
+ xdlclassifier_t *cf, xdfile_t *xdf, xrecord_t **arec);
@rctay
rctay / gist:1099236
Created July 22, 2011 10:46
[gsoc-diff] skip hashing of common leading lines
diff --git a/xdiff/xprepare.c b/xdiff/xprepare.c
index 82bff88..f926966 100644
--- a/xdiff/xprepare.c
+++ b/xdiff/xprepare.c
@@ -55,7 +55,7 @@ static void xdl_free_classifier(xdlclassifier_t *cf);
static int xdl_classify_record(xdlclassifier_t *cf, xrecord_t **rhash, unsigned int hbits,
xrecord_t *rec);
static int xdl_prepare_ctx(mmfile_t *mf, long narec, xpparam_t const *xpp,
- xdlclassifier_t *cf, xdfile_t *xdf);
@rctay
rctay / gist:1098863
Created July 22, 2011 04:07
[gsoc-diff] make trim tail support context
diff --git a/xdiff-interface.c b/xdiff-interface.c
index e1e054e..74a8571 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -108,10 +108,9 @@ static void trim_common_tail(mmfile_t *a, mmfile_t *b, long ctx)
long trimmed = 0, recovered = 0;
char *ap = a->ptr + a->size;
char *bp = b->ptr + b->size;
+ char *atop = ap, *prev;
long smaller = (a->size < b->size) ? a->size : b->size;
@rctay
rctay / cha_alloc.diff
Created July 10, 2011 17:12
[gsoc-diff] reduce number of mallocs for gd-ptr
diff --git a/xdiff/xhistogram.c b/xdiff/xhistogram.c
index acb43d1..0bca160 100644
--- a/xdiff/xhistogram.c
+++ b/xdiff/xhistogram.c
@@ -14,6 +14,7 @@ struct histindex {
struct record *next;
} **records, /* an ocurrence */
**line_map; /* map of line to record chain */
+ chastore_t rcha;
unsigned int *next_ptrs;
@rctay
rctay / raw.foo.diff
Created July 7, 2011 08:35
[gsoc-diff] reduce number of rec accesses
diff --git a/xdiff/xhistogram.c b/xdiff/xhistogram.c
index ea7b82d..d26c57c 100644
--- a/xdiff/xhistogram.c
+++ b/xdiff/xhistogram.c
@@ -52,7 +52,7 @@ struct region {
#define get_rec(env, s, l) \
(env->xdf##s.recs[l-1])
-static int cmp_recs(xpparam_t const *xpp, xdfenv_t *env,
+static int cmp_recs(xpparam_t const *xpp,
@rctay
rctay / gist:1068912
Created July 7, 2011 05:03
[gsoc-diff] malloc()/free() once
diff --git a/xdiff/xhistogram.c b/xdiff/xhistogram.c
index ea7b82d..2e63235 100644
--- a/xdiff/xhistogram.c
+++ b/xdiff/xhistogram.c
@@ -237,12 +237,10 @@ static int fall_back_to_classic_diff(struct histindex *index,
line1, count1, line2, count2);
}
-static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
+static int histogram_diff(struct histindex *index,
@rctay
rctay / gist:1066906
Created July 6, 2011 09:28
[gsoc-diff] diff --assume-text
diff --git a/diff.c b/diff.c
index 1b940ee..66b998e 100644
--- a/diff.c
+++ b/diff.c
@@ -2854,11 +2854,13 @@ static void run_diff_cmd(const char *pgm,
complete_rewrite);
return;
}
- if (one && two)
+ if (one && two) {
@rctay
rctay / gist:1066773
Created July 6, 2011 07:54
[gsoc-diff] try_lcs: skip chains
diff --git a/xdiff/xhistogram.c b/xdiff/xhistogram.c
index e65bc29..fb7f17a 100644
--- a/xdiff/xhistogram.c
+++ b/xdiff/xhistogram.c
@@ -11,6 +11,7 @@
struct histindex {
struct record {
unsigned int ptr, cnt;
+ unsigned long *ha;
struct record *next, *head;
@rctay
rctay / ptr.golden.diff
Created July 6, 2011 07:00
[gsoc-diff] alternate hashing ("golden ratio")
diff --git a/xdiff/xhistogram.c b/xdiff/xhistogram.c
index 789f4e5..28e74ae 100644
--- a/xdiff/xhistogram.c
+++ b/xdiff/xhistogram.c
@@ -58,8 +58,38 @@ static int cmp_recs(xpparam_t const *xpp, xdfenv_t *env,
#define cmp(i, s1, l1, s2, l2) \
(cmp_env(i->xpp, i->env, s1, l1, s2, l2))
+/*
+ * From http://en.wikipedia.org/wiki/Binary_logarithm#Integer