Fossil SCM

Fix problems in the new content_deltify() routine.

drh 2017-09-19 03:57 trunk
Commit cb29bc646b63a9c86fc7e55a721b8a3a1b5433f246248f9befbc5cf6c626f276
1 file changed +2 -2
+2 -2
--- src/content.c
+++ src/content.c
@@ -849,11 +849,11 @@
849849
blob_reset(&src);
850850
continue;
851851
}
852852
blob_delta_create(&src, &data, &delta);
853853
if( blob_size(&delta) < blob_size(&data)*0.75
854
- && (bestSrc<0 || blob_size(&delta)<blob_size(&bestDelta))
854
+ && (bestSrc<=0 || blob_size(&delta)<blob_size(&bestDelta))
855855
){
856856
/* This is the best delta seen so far. Remember it */
857857
blob_reset(&bestDelta);
858858
bestDelta = delta;
859859
bestSrc = srcid;
@@ -866,11 +866,11 @@
866866
867867
/* If there is a winning candidate for the new parent of rid, then
868868
** make that candidate the new parent now */
869869
if( bestSrc>0 ){
870870
Stmt s1, s2; /* Statements used to create the delta */
871
- blob_compress(&delta, &delta);
871
+ blob_compress(&bestDelta, &bestDelta);
872872
db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid);
873873
db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,%d)", rid, bestSrc);
874874
db_bind_blob(&s1, ":data", &bestDelta);
875875
db_begin_transaction();
876876
db_exec(&s1);
877877
--- src/content.c
+++ src/content.c
@@ -849,11 +849,11 @@
849 blob_reset(&src);
850 continue;
851 }
852 blob_delta_create(&src, &data, &delta);
853 if( blob_size(&delta) < blob_size(&data)*0.75
854 && (bestSrc<0 || blob_size(&delta)<blob_size(&bestDelta))
855 ){
856 /* This is the best delta seen so far. Remember it */
857 blob_reset(&bestDelta);
858 bestDelta = delta;
859 bestSrc = srcid;
@@ -866,11 +866,11 @@
866
867 /* If there is a winning candidate for the new parent of rid, then
868 ** make that candidate the new parent now */
869 if( bestSrc>0 ){
870 Stmt s1, s2; /* Statements used to create the delta */
871 blob_compress(&delta, &delta);
872 db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid);
873 db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,%d)", rid, bestSrc);
874 db_bind_blob(&s1, ":data", &bestDelta);
875 db_begin_transaction();
876 db_exec(&s1);
877
--- src/content.c
+++ src/content.c
@@ -849,11 +849,11 @@
849 blob_reset(&src);
850 continue;
851 }
852 blob_delta_create(&src, &data, &delta);
853 if( blob_size(&delta) < blob_size(&data)*0.75
854 && (bestSrc<=0 || blob_size(&delta)<blob_size(&bestDelta))
855 ){
856 /* This is the best delta seen so far. Remember it */
857 blob_reset(&bestDelta);
858 bestDelta = delta;
859 bestSrc = srcid;
@@ -866,11 +866,11 @@
866
867 /* If there is a winning candidate for the new parent of rid, then
868 ** make that candidate the new parent now */
869 if( bestSrc>0 ){
870 Stmt s1, s2; /* Statements used to create the delta */
871 blob_compress(&bestDelta, &bestDelta);
872 db_prepare(&s1, "UPDATE blob SET content=:data WHERE rid=%d", rid);
873 db_prepare(&s2, "REPLACE INTO delta(rid,srcid)VALUES(%d,%d)", rid, bestSrc);
874 db_bind_blob(&s1, ":data", &bestDelta);
875 db_begin_transaction();
876 db_exec(&s1);
877

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button