From 8806a01b33d1b85b3d3f2ea3352b4c538bb4f5d6 Mon Sep 17 00:00:00 2001 From: scorpion Date: Fri, 17 Oct 2014 04:58:41 -0500 Subject: [PATCH] Renames for clarity --- deltaq/BsPatch.cs | 31 +++++++++++++++---------------- deltaq/SAIS.cs | 9 ++++----- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/deltaq/BsPatch.cs b/deltaq/BsPatch.cs index 0b5181b..3c0b5cf 100644 --- a/deltaq/BsPatch.cs +++ b/deltaq/BsPatch.cs @@ -5,13 +5,12 @@ namespace deltaq { public static class BsPatch { - public delegate Stream OpenDiffStream(long offset, long length); + public delegate Stream OpenPatchStream(long offset, long length); public static void Apply(byte[] input, byte[] diff, Stream output) { - OpenDiffStream openDiffStream = (uOffset, uLength) => + OpenPatchStream openPatchStream = (uOffset, uLength) => { - //shaving down to int because we assume we're using 32bit indices var offset = (int)uOffset; var length = (int)uLength; return new MemoryStream(diff, offset, @@ -21,35 +20,35 @@ public static void Apply(byte[] input, byte[] diff, Stream output) }; Stream controlStream, diffStream, extraStream; - var newSize = CreatePatchStreams(openDiffStream, out controlStream, out diffStream, out extraStream); + var newSize = CreatePatchStreams(openPatchStream, out controlStream, out diffStream, out extraStream); // prepare to read three parts of the patch in parallel ApplyInternal(newSize, new MemoryStream(input), controlStream, diffStream, extraStream, output); } - public static void Apply(Stream input, OpenDiffStream openDiffStream, Stream output) + public static void Apply(Stream input, OpenPatchStream openPatchStream, Stream output) { Stream controlStream, diffStream, extraStream; - var newSize = CreatePatchStreams(openDiffStream, out controlStream, out diffStream, out extraStream); + var newSize = CreatePatchStreams(openPatchStream, out controlStream, out diffStream, out extraStream); // prepare to read three parts of the patch in parallel ApplyInternal(newSize, input, controlStream, diffStream, extraStream, output); } - private static long CreatePatchStreams(OpenDiffStream openDiffStream, out Stream ctrl, out Stream diff, out Stream extra) + private static long CreatePatchStreams(OpenPatchStream openPatchStream, out Stream ctrl, out Stream diff, out Stream extra) { // read header long controlLength, diffLength, newSize; - using (var diffStream = openDiffStream(0, BsDiff.HeaderSize)) + using (var patchStream = openPatchStream(0, BsDiff.HeaderSize)) { // check patch stream capabilities - if (!diffStream.CanRead) - throw new ArgumentException("Patch stream must be readable", "openDiffStream"); - if (!diffStream.CanSeek) - throw new ArgumentException("Patch stream must be seekable", "openDiffStream"); + if (!patchStream.CanRead) + throw new ArgumentException("Patch stream must be readable", "openPatchStream"); + if (!patchStream.CanSeek) + throw new ArgumentException("Patch stream must be seekable", "openPatchStream"); var header = new byte[BsDiff.HeaderSize]; - diffStream.Read(header, 0, BsDiff.HeaderSize); + patchStream.Read(header, 0, BsDiff.HeaderSize); // check for appropriate magic var signature = header.ReadLong(); @@ -67,9 +66,9 @@ private static long CreatePatchStreams(OpenDiffStream openDiffStream, out Stream // prepare to read three parts of the patch in parallel Stream - compressedControlStream = openDiffStream(BsDiff.HeaderSize, controlLength), - compressedDiffStream = openDiffStream(BsDiff.HeaderSize + controlLength, diffLength), - compressedExtraStream = openDiffStream(BsDiff.HeaderSize + controlLength + diffLength, -1); + compressedControlStream = openPatchStream(BsDiff.HeaderSize, controlLength), + compressedDiffStream = openPatchStream(BsDiff.HeaderSize + controlLength, diffLength), + compressedExtraStream = openPatchStream(BsDiff.HeaderSize + controlLength + diffLength, -1); // decompress each part (to read it) ctrl = BsDiff.GetEncodingStream(compressedControlStream, false); diff --git a/deltaq/SAIS.cs b/deltaq/SAIS.cs index eb28f1e..8a40eeb 100644 --- a/deltaq/SAIS.cs +++ b/deltaq/SAIS.cs @@ -155,7 +155,7 @@ private static void GetBuckets(IList c, IList b, int k, bool end) } /* sort all type LMS suffixes */ - private static void LMSsort(IList T, int[] sa, IList c, IList B, int n, int k) + private static void LMS_sort(IList T, int[] sa, IList c, IList B, int n, int k) { int b, i, j; int c0, c1; @@ -207,7 +207,7 @@ private static void LMSsort(IList T, int[] sa, IList c, IList B, } } - private static int LMSpostproc(IList T, int[] sa, int n, int m) + private static int LMS_post_proc(IList T, int[] sa, int n, int m) { int i, j, p, q, plen, qlen, name; int c0, c1; @@ -432,8 +432,8 @@ sort all the LMS-substrings */ } if (1 < m) { - LMSsort(T, sa, c, B, n, k); - name = LMSpostproc(T, sa, n, m); + LMS_sort(T, sa, c, B, n, k); + name = LMS_post_proc(T, sa, n, m); } else if (m == 1) { @@ -480,7 +480,6 @@ sort all the LMS-substrings */ RA = new ArraySegment(sa, m + newfs, sa.Length - (m + newfs)); sais_main(RA, sa, newfs, m, name); - RA = null; i = n - 1; j = m * 2 - 1;