comparison src/line-number.c @ 298:70ad99077275 r21-0b47

Import from CVS: tag r21-0b47
author cvs
date Mon, 13 Aug 2007 10:39:40 +0200
parents 57709be46d1b
children 6240c7796c7a
comparison
equal deleted inserted replaced
297:deca3c1083ac 298:70ad99077275
65 #define LINE_NUMBER_RING_SIZE 8 65 #define LINE_NUMBER_RING_SIZE 8
66 66
67 /* How much traversal has to be exceeded for two points to be 67 /* How much traversal has to be exceeded for two points to be
68 considered "far" from each other. When two points are far, cache 68 considered "far" from each other. When two points are far, cache
69 will be used. */ 69 will be used. */
70 #define LINE_NUMBER_FAR 32768 70 #define LINE_NUMBER_FAR 16384
71 71
72 /* How large a string has to be to give up searching it for newlines, 72 /* How large a string has to be to give up searching it for newlines,
73 before change. */ 73 before change. */
74 #define LINE_NUMBER_LARGE_STRING 256 74 #define LINE_NUMBER_LARGE_STRING 256
75 75
193 scan_buffer (b, '\n', from, to, 1, &shortage, 0); 193 scan_buffer (b, '\n', from, to, 1, &shortage, 0);
194 if (!shortage) 194 if (!shortage)
195 invalidate_line_number_cache (b, from); 195 invalidate_line_number_cache (b, from);
196 } 196 }
197 } 197 }
198
199 198
200 /* Get the nearest known position we know the line number of 199 /* Get the nearest known position we know the line number of
201 (i.e. BUF_BEGV, and cached positions). The return position will be 200 (i.e. BUF_BEGV, and cached positions). The return position will be
202 either closer than BEG, or BEG. The line of this known position 201 either closer than BEG, or BEG. The line of this known position
203 will be stored in LINE. 202 will be stored in LINE.
232 } 231 }
233 } 232 }
234 233
235 /* Add a (POS . LINE) pair to the ring, and rotate it. */ 234 /* Add a (POS . LINE) pair to the ring, and rotate it. */
236 static void 235 static void
237 add_position_to_cache (struct buffer *b, Bufpos pos, int line) 236 add_position_to_cache (struct buffer *b, Bufpos pos, EMACS_INT line)
238 { 237 {
239 Lisp_Object *ring = XVECTOR_DATA (LINE_NUMBER_RING (b)); 238 Lisp_Object *ring = XVECTOR_DATA (LINE_NUMBER_RING (b));
240 int i = LINE_NUMBER_RING_SIZE - 1; 239 int i = LINE_NUMBER_RING_SIZE - 1;
241 240
242 /* Set the last marker in the ring to point nowhere. */ 241 /* Set the last marker in the ring to point nowhere. */
293 } 292 }
294 cached_lines = XINT (LINE_NUMBER_BEGV (b)); 293 cached_lines = XINT (LINE_NUMBER_BEGV (b));
295 get_nearest_line_number (b, &beg, pos, &cached_lines); 294 get_nearest_line_number (b, &beg, pos, &cached_lines);
296 } 295 }
297 296
298 /* An EMACS_MAXINT would be cool to have. */ 297 scan_buffer (b, '\n', beg, pos, pos > beg ? EMACS_INT_MAX : -EMACS_INT_MAX,
299 #define LOTS 999999999 298 &shortage, 0);
300 299
301 scan_buffer (b, '\n', beg, pos, pos > beg ? LOTS : -LOTS, &shortage, 0); 300 line = EMACS_INT_MAX - shortage;
302
303 line = LOTS - shortage;
304 if (beg > pos) 301 if (beg > pos)
305 line = -line; 302 line = -line;
306 line += cached_lines; 303 line += cached_lines;
307 304
308 if (cachep) 305 if (cachep)