Repository: neovim/neovim
File: src/nvim/memline_defs.h (C/C++)

Code before:
/// Memline also has "chunks" of 800 lines that are separate from the 128-tree
/// structure, primarily used to speed up line2byte() and byte2line().
///
/// Motivation: If you have a file that is 10000 lines long, and you insert
///             a line at linenr 1000, you don't want to move 9000 lines in
///             memory.  With this structure it is roughly (N * 128) pointer
///             moves, where N is the height (typically 1-3).
///
typedef struct {
  linenr_T ml_line_count;       // number of lines in the buffer

  memfile_T *ml_mfp;          // pointer to associated memfile

  infoptr_T *ml_stack;        // stack of pointer blocks (array of IPTRs)
  int ml_stack_top;             // current top of ml_stack
  int ml_stack_size;            // total number of entries in ml_stack

#define ML_EMPTY        0x01    // empty buffer
#define ML_LINE_DIRTY   0x02    // cached line was changed and allocated
#define ML_LOCKED_DIRTY 0x04    // ml_locked was changed
#define ML_LOCKED_POS   0x08    // ml_locked needs positive block number
#define ML_ALLOCATED    0x10    // ml_line_ptr is an allocated copy
  int ml_flags;

  // colnr_T ml_line_len;
  colnr_T ml_line_textlen;      // length of the cached line + NUL, 0 if not known yet
  linenr_T ml_line_lnum;        // line number of cached line, 0 if not valid
  char *ml_line_ptr;            // pointer to cached line
  size_t ml_line_offset;        // cached byte offset of ml_line_lnum
  int ml_line_offset_ff;        // fileformat of cached line

  bhdr_T *ml_locked;       // block used by last ml_get
  linenr_T ml_locked_low;       // first line in ml_locked
  linenr_T ml_locked_high;      // last line in ml_locked
  int ml_locked_lineadd;        // number of lines inserted in ml_locked
  chunksize_T *ml_chunksize;
  int ml_numchunks;
  int ml_usedchunks;
} memline_T;


Review comment (performance):
```suggestion
  colnr_T ml_line_textlen;      // length of the cached line + NUL
```

Code after:
/// Memline also has "chunks" of 800 lines that are separate from the 128-tree
/// structure, primarily used to speed up line2byte() and byte2line().
///
/// Motivation: If you have a file that is 10000 lines long, and you insert
///             a line at linenr 1000, you don't want to move 9000 lines in
///             memory.  With this structure it is roughly (N * 128) pointer
///             moves, where N is the height (typically 1-3).
///
typedef struct {
  linenr_T ml_line_count;       // number of lines in the buffer

  memfile_T *ml_mfp;          // pointer to associated memfile

  infoptr_T *ml_stack;        // stack of pointer blocks (array of IPTRs)
  int ml_stack_top;             // current top of ml_stack
  int ml_stack_size;            // total number of entries in ml_stack

#define ML_EMPTY        0x01    // empty buffer
#define ML_LINE_DIRTY   0x02    // cached line was changed and allocated
#define ML_LOCKED_DIRTY 0x04    // ml_locked was changed
#define ML_LOCKED_POS   0x08    // ml_locked needs positive block number
#define ML_ALLOCATED    0x10    // ml_line_ptr is an allocated copy
  int ml_flags;

  // colnr_T ml_line_len;
  colnr_T ml_line_textlen;      // length of the cached line + NUL
  linenr_T ml_line_lnum;        // line number of cached line, 0 if not valid
  char *ml_line_ptr;            // pointer to cached line
  size_t ml_line_offset;        // cached byte offset of ml_line_lnum
  int ml_line_offset_ff;        // fileformat of cached line

  bhdr_T *ml_locked;       // block used by last ml_get
  linenr_T ml_locked_low;       // first line in ml_locked
  linenr_T ml_locked_high;      // last line in ml_locked
  int ml_locked_lineadd;        // number of lines inserted in ml_locked
  chunksize_T *ml_chunksize;
  int ml_numchunks;
  int ml_usedchunks;
} memline_T;