mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 05:52:55 +08:00
Apply refactorings from review
This commit is contained in:
parent
c178e5d592
commit
f680f4d26b
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiffPlex;
|
using DiffPlex;
|
||||||
@ -63,8 +62,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
{
|
{
|
||||||
findChangedIndices(result, LegacyDecoder<Beatmap>.Section.HitObjects, out var removedIndices, out var addedIndices);
|
findChangedIndices(result, LegacyDecoder<Beatmap>.Section.HitObjects, out var removedIndices, out var addedIndices);
|
||||||
|
|
||||||
foreach (int removed in removedIndices)
|
for (int i = removedIndices.Count - 1; i >= 0; i--)
|
||||||
editorBeatmap.RemoveAt(removed);
|
editorBeatmap.RemoveAt(removedIndices[i]);
|
||||||
|
|
||||||
if (addedIndices.Count > 0)
|
if (addedIndices.Count > 0)
|
||||||
{
|
{
|
||||||
@ -80,7 +79,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
removedIndices = new List<int>();
|
removedIndices = new List<int>();
|
||||||
addedIndices = new List<int>();
|
addedIndices = new List<int>();
|
||||||
|
|
||||||
// Find the index of [HitObject] sections. Lines changed prior to this index are ignored.
|
// Find the start and end indices of the relevant section headers in both the old and the new beatmap file. Lines changed outside of the modified ranges are ignored.
|
||||||
int oldSectionStartIndex = Array.IndexOf(result.PiecesOld, $"[{section}]");
|
int oldSectionStartIndex = Array.IndexOf(result.PiecesOld, $"[{section}]");
|
||||||
if (oldSectionStartIndex == -1)
|
if (oldSectionStartIndex == -1)
|
||||||
return;
|
return;
|
||||||
@ -97,9 +96,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
if (newSectionEndIndex == -1)
|
if (newSectionEndIndex == -1)
|
||||||
newSectionEndIndex = result.PiecesNew.Length;
|
newSectionEndIndex = result.PiecesNew.Length;
|
||||||
|
|
||||||
Debug.Assert(oldSectionStartIndex >= 0);
|
|
||||||
Debug.Assert(newSectionStartIndex >= 0);
|
|
||||||
|
|
||||||
foreach (var block in result.DiffBlocks)
|
foreach (var block in result.DiffBlocks)
|
||||||
{
|
{
|
||||||
// Removed indices
|
// Removed indices
|
||||||
@ -129,10 +125,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
// This isn't strictly required, but the differ makes no guarantees about order.
|
// This isn't strictly required, but the differ makes no guarantees about order.
|
||||||
removedIndices.Sort();
|
removedIndices.Sort();
|
||||||
addedIndices.Sort();
|
addedIndices.Sort();
|
||||||
|
|
||||||
// The expected usage of this returned list is to iterate from the start to the end of the list, such that
|
|
||||||
// these indices need to appear in reverse order for the usage to not have to deal with decrementing indices.
|
|
||||||
removedIndices.Reverse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string readString(byte[] state) => Encoding.UTF8.GetString(state);
|
private string readString(byte[] state) => Encoding.UTF8.GetString(state);
|
||||||
|
Loading…
Reference in New Issue
Block a user