##// END OF EJS Templates
sparse-revlog: add a `trim_endidx` function in C...
Boris Feld -
r40742:0650be87 default
parent child Browse files
Show More
@@ -1078,6 +1078,24 b' index_segment_span(indexObject *self, Py'
1078 return (end_offset - start_offset) + (int64_t)end_size;
1078 return (end_offset - start_offset) + (int64_t)end_size;
1079 }
1079 }
1080
1080
1081 /* returns revs[startidx:endidx] without empty trailing revs */
1082 static Py_ssize_t trim_endidx(indexObject *self, const Py_ssize_t *revs,
1083 Py_ssize_t startidx, Py_ssize_t endidx)
1084 {
1085 int length;
1086 while (endidx > 1 && endidx > startidx) {
1087 length = index_get_length(self, revs[endidx - 1]);
1088 if (length < 0) {
1089 return -1;
1090 }
1091 if (length != 0) {
1092 break;
1093 }
1094 endidx -= 1;
1095 }
1096 return endidx;
1097 }
1098
1081 static inline int nt_level(const char *node, Py_ssize_t level)
1099 static inline int nt_level(const char *node, Py_ssize_t level)
1082 {
1100 {
1083 int v = node[level >> 1];
1101 int v = node[level >> 1];
General Comments 0
You need to be logged in to leave comments. Login now