MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / apply_line_index_updates

Function apply_line_index_updates

atomic-cli/src/commands/git/parallel.rs:4036–4162  ·  view source on GitHub ↗
(
    line_index: &mut ImportLineIndex,
    change_hash: ContentHash,
    pending: Vec<PendingLineIndexUpdate>,
)

Source from the content-addressed store, hash-verified

4034}
4035
4036fn apply_line_index_updates(
4037 line_index: &mut ImportLineIndex,
4038 change_hash: ContentHash,
4039 pending: Vec<PendingLineIndexUpdate>,
4040) {
4041 for update in pending {
4042 match update {
4043 PendingLineIndexUpdate::DirectoryAdd { path, inode_pos } => {
4044 line_index.directories.insert(
4045 path,
4046 Position {
4047 change: Some(change_hash),
4048 pos: inode_pos.pos,
4049 },
4050 );
4051 }
4052 PendingLineIndexUpdate::Add {
4053 path,
4054 inode_pos,
4055 new_ranges,
4056 new_lines,
4057 } => {
4058 let inode_pos = Position {
4059 change: Some(change_hash),
4060 pos: inode_pos.pos,
4061 };
4062 let lines = new_ranges
4063 .iter()
4064 .zip(new_lines)
4065 .enumerate()
4066 .map(|(index, (&(start, end), content))| ImportLine {
4067 change: change_hash,
4068 start,
4069 end,
4070 incoming_by: change_hash,
4071 incoming_from: if index == 0 {
4072 inode_pos
4073 } else {
4074 Position {
4075 change: Some(change_hash),
4076 pos: new_ranges[index - 1].1,
4077 }
4078 },
4079 content,
4080 })
4081 .collect();
4082 line_index.files.insert(
4083 path,
4084 ImportIndexedFile {
4085 inode_pos,
4086 lines,
4087 imported_commits: 1,
4088 },
4089 );
4090 }
4091 PendingLineIndexUpdate::Modify { path, replacements } => {
4092 let Some(indexed) = line_index.files.get_mut(&path) else {
4093 continue;

Calls 9

get_mutMethod · 0.80
getMethod · 0.65
removeMethod · 0.65
insertMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45
end_posMethod · 0.45