Browse code

Disable with a define the generation of a file hash in each undo element (it is too slow with large files)

Dario Rodriguez authored on 09/10/2020 21:43:36
Showing 2 changed files
... ...
@@ -24,8 +24,10 @@
24 24
 #include "sha3/sha3.h"
25 25
 
26 26
 //#define CHUNKSIZE 32768
27
+//#define CHUNKSIZE 4096
28
+#define CHUNKSIZE 1024
27 29
 //#define CHUNKSIZE 160
28
-#define CHUNKSIZE 16
30
+//#define CHUNKSIZE 16
29 31
 #define UNDOBLOCK 1024
30 32
 #define ADDNBLOCK 1024
31 33
 #define UNDOGROWSIZE (256*1024)
... ...
@@ -846,8 +848,10 @@ redata_undo_movelast(redata_t *redata, undostack_t *from, undostack_t *to)
846 848
                 return(-1); /* insuf. mem. */
847 849
         undoto->posorig=undofrom->posorig;
848 850
         undoto->posdest=undofrom->posdest;
851
+#ifdef REDATA_HASHUNDO
849 852
         memcpy(undoto->prehash,undofrom->prehash,sizeof(undoto->prehash));
850 853
         memcpy(undoto->posthash,undofrom->posthash,sizeof(undoto->posthash));
854
+#endif
851 855
         redata_undo_removelast(redata, from);
852 856
         return(0);
853 857
 }
... ...
@@ -945,7 +949,9 @@ redata_op_add(redata_t *redata, long insertpos, char *buf, long buflen, undostac
945 949
         if(fromhere!=&(redata->undostack)) {
946 950
                 if((undo=redata_undo_newfrombuf(redata,&(redata->undostack),'A',buf,buflen))==NULL)
947 951
                         return(-1); /* couldn't create undo struct */
952
+#ifdef REDATA_HASHUNDO
948 953
                 redata_hash(redata,undo->prehash);
954
+#endif
949 955
         } else {
950 956
                 undo=NULL;
951 957
         }
... ...
@@ -1005,7 +1011,9 @@ redata_op_add(redata_t *redata, long insertpos, char *buf, long buflen, undostac
1005 1011
         if(undo!=NULL) {
1006 1012
                 /* new or from redo stack */
1007 1013
                 undo->posorig=undo->posdest=insertpos;
1014
+#ifdef REDATA_HASHUNDO
1008 1015
                 redata_hash(redata,undo->posthash);
1016
+#endif
1009 1017
                 if(fromhere==&(redata->redostack))
1010 1018
                         redata_undo_removelast(redata,&(redata->redostack));
1011 1019
                 else
... ...
@@ -1067,7 +1075,9 @@ redata_op_del(redata_t *redata, long delpos, long size, undostack_t *fromhere)
1067 1075
         if(fromhere!=&(redata->undostack)) {
1068 1076
                 if((undo=redata_undo_newfromchunks(redata,&(redata->undostack),'D',delpos,size))==NULL)
1069 1077
                         return(-1); /* couldn't create undo struct */
1078
+#ifdef REDATA_HASHUNDO
1070 1079
                 redata_hash(redata,undo->prehash);
1080
+#endif
1071 1081
         } else {
1072 1082
                 undo=NULL;
1073 1083
         }
... ...
@@ -1091,7 +1101,9 @@ redata_op_del(redata_t *redata, long delpos, long size, undostack_t *fromhere)
1091 1101
         if(undo!=NULL) {
1092 1102
                 /* new or from redo stack */
1093 1103
                 undo->posorig=undo->posdest=delpos;
1104
+#ifdef REDATA_HASHUNDO
1094 1105
                 redata_hash(redata,undo->posthash);
1106
+#endif
1095 1107
                 if(fromhere==&(redata->redostack))
1096 1108
                         redata_undo_removelast(redata,&(redata->redostack));
1097 1109
                 else
... ...
@@ -1135,7 +1147,9 @@ redata_op_move(redata_t *redata, long posorig, long size, long posdest, undostac
1135 1147
                         return(-1); /* couldn't create undo struct */
1136 1148
                 /* inactivate the undo so we are able to use return(-1) without removing it */
1137 1149
                 redata_undo_inactivatelast(redata,&(redata->undostack));
1150
+#ifdef REDATA_HASHUNDO
1138 1151
                 redata_hash(redata,undo->prehash);
1152
+#endif
1139 1153
         } else {
1140 1154
                 undo=NULL;
1141 1155
         }
... ...
@@ -1226,7 +1240,9 @@ redata_op_move(redata_t *redata, long posorig, long size, long posdest, undostac
1226 1240
                 /* new or from redo stack */
1227 1241
                 undo->posorig=posorig;
1228 1242
                 undo->posdest=posdest;
1243
+#ifdef REDATA_HASHUNDO
1229 1244
                 redata_hash(redata,undo->posthash);
1245
+#endif
1230 1246
                 if(fromhere==&(redata->redostack))
1231 1247
                         redata_undo_removelast(redata,&(redata->redostack));
1232 1248
                 else
... ...
@@ -47,9 +47,11 @@ typedef struct undo_t {
47 47
         long len;
48 48
         long posorig;
49 49
         long posdest;
50
+        int hint_groupedwithnext;
51
+#ifdef REDATA_HASHUNDO
50 52
         char prehash[129];
51 53
         char posthash[129];
52
-        int hint_groupedwithnext;
54
+#endif
53 55
 } undo_t;
54 56
 
55 57
 typedef struct undostack_t {