Last active
January 31, 2019 17:40
-
-
Save MarkGoldberg/c22d6ea39292b0acfce5245af5e29f34 to your computer and use it in GitHub Desktop.
A refactored FileManager.EqualBuffer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FileManager.EqualBuffer PROCEDURE(*USHORT Id) | |
! Why *USHORT, Id is never altered, so why not pass by value ? | |
RetAreEqual BYTE(TRUE) | |
CODE | |
IF SELF.UseFile()<>Level:Benign ! Is this needed? Should a buffer compare require an open file? | |
OR SELF.BlobChanged ! A blob has changed so the buffers are unequal | |
THEN | |
RetAreEqual = FALSE | |
ELSIF SELF.FindBuffer( Id ) <> NoError | |
? ASSERT(FALSE,'Restore handle is invalid') | |
RetAreEqual = FALSE ! note: this is a change from SV's shipping version of this method where the answer might be true or false | |
ELSIF SELF.Buffer <> SELF.Buffers.Buffer | |
RetAreEqual = FALSE | |
ELSE | |
DO EqualBuffer:CheckMemos | |
END | |
RETURN RetAreEqual | |
EqualBuffer:CheckMemos ROUTINE | |
DATA | |
I SHORT,AUTO | |
CODE | |
LOOP I = 1 TO SELF.File{PROP:Memos} | |
IF SELF.FindBuffer( Id + I ) <> NoError | |
? ASSERT(FALSE,'Restore handle is invalid (memo does not appear to have been stored)') | |
RetAreEqual = FALSE ! note: this is a change from SV's shipping version of this method where the answer might be true or false | |
ELSIF SELF.File{PROP:Value,-I} <> SELF.Buffers.Buffer | |
RetAreEqual = FALSE | |
BREAK | |
END | |
END | |
FileManager.FindBuffer PROCEDURE(LONG xID)!,LONG ! returns ErrorCode | |
CODE | |
SELF.Buffers.ID = xID | |
GET(SELF.Buffers, SELF.Buffers.ID) | |
RETURN ErrorCode() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment