Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | speed-up looks_like_text(), by eliminating variable "i" and handle first character separately. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
204680eedc0232952480fb932897ac59 |
| User & Date: | jan.nijtmans 2012-10-28 20:40:55.642 |
| Original Comment: | speed-up lools_like_text(), by eliminating variable "i" and handle first character separately. |
Context
|
2012-10-28
| ||
| 20:47 | .. but don't forget to update j ... (check-in: 6542935c9d user: jan.nijtmans tags: trunk) | |
| 20:40 | speed-up looks_like_text(), by eliminating variable "i" and handle first character separately. ... (check-in: 204680eedc user: jan.nijtmans tags: trunk) | |
| 17:28 | Performance enhancement for branch name look-ups. ... (check-in: 186405ce3a user: drh tags: trunk) | |
Changes
Changes to src/diff.c.
| ︙ | ︙ | |||
175 176 177 178 179 180 181 |
** Returns 1, if the file appears text, and does not contain CrLf
** Returns 0 if the specified content appears to be binary or
** contains a line that is too long
** Returns -1, if the file appears text, but it contains CrLf
*/
int looks_like_text(const Blob *pContent){
const char *z = blob_buffer(pContent);
| | | | | | > > > > | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
** Returns 1, if the file appears text, and does not contain CrLf
** Returns 0 if the specified content appears to be binary or
** contains a line that is too long
** Returns -1, if the file appears text, but it contains CrLf
*/
int looks_like_text(const Blob *pContent){
const char *z = blob_buffer(pContent);
unsigned int n = blob_size(pContent);
int j, c;
int result = 1;
/* Check individual lines.
*/
if( n==0 ) return 1; /* Empty file -> text */
c = *z;
if( c==0 ) return 0; /* \000 byte in a file -> binary */
j = (c!='\n');
while( --n>0 ){
c = *++z;
if( c==0 ) return 0; /* \000 byte in a file -> binary */
if( c=='\n' ){
if( z[-1]=='\r' ){
result = -1; /* Contains CrLf, continue */
}
if( j>LENGTH_MASK ){
return 0; /* Very long line -> binary */
}
j = 0;
}
|
| ︙ | ︙ |