SynEdit: Undo initializations, if value is either not needed or always set.

git-svn-id: trunk@48497 -
This commit is contained in:
martin 2015-03-24 23:13:33 +00:00
parent 7b6b5c3ce1
commit a2ec42e01e
10 changed files with 20 additions and 50 deletions

View File

@ -869,7 +869,6 @@ begin
{$ENDIF} {$ENDIF}
PrepareWidthsForLine(AIndex); PrepareWidthsForLine(AIndex);
Result := 0;
dec(ABytePos); dec(ABytePos);
if ABytePos < FCurrentWidthsLen then begin if ABytePos < FCurrentWidthsLen then begin
if (FCurrentWidths[ABytePos] and PCWMask) = 0 then begin if (FCurrentWidths[ABytePos] and PCWMask) = 0 then begin

View File

@ -1551,6 +1551,7 @@ var
LineBufferLen := Len + ATokenInfo.ExpandedExtraBytes + 1 + 128; LineBufferLen := Len + ATokenInfo.ExpandedExtraBytes + 1 + 128;
ReAllocMem(LineBuffer, LineBufferLen); ReAllocMem(LineBuffer, LineBufferLen);
end; end;
pl := LineBuffer;
end; end;
// Prepare FETOBuf // Prepare FETOBuf
@ -1563,9 +1564,8 @@ var
end end
else else
c := 0; c := 0;
e := 0;
pl := LineBuffer;
e := 0;
CWLen := Length(CharWidths); CWLen := Length(CharWidths);
// Copy to LineBuffer (and maybe FetoBuf // Copy to LineBuffer (and maybe FetoBuf

View File

@ -805,7 +805,6 @@ end;
function TSynBeautifierPascal.GetMatchStartColForIdx(AIndex: Integer): Integer; function TSynBeautifierPascal.GetMatchStartColForIdx(AIndex: Integer): Integer;
begin begin
Result := -1;
if ToPos(AIndex) = GetFirstCommentLine then begin if ToPos(AIndex) = GetFirstCommentLine then begin
// Match on FirstLine // Match on FirstLine
case FMatchMode[FWorkFoldType] of case FMatchMode[FWorkFoldType] of
@ -1749,7 +1748,6 @@ var
FoundLine: LongInt; FoundLine: LongInt;
begin begin
Result := 1; Result := 1;
Temp := '';
FCurrentLines := Lines; // for GetCurrentIndent FCurrentLines := Lines; // for GetCurrentIndent
BackCounter := ACaret.LinePos - 1; BackCounter := ACaret.LinePos - 1;
if BackCounter > 0 then if BackCounter > 0 then

View File

@ -1895,9 +1895,7 @@ begin
if eoFoldedCopyPaste in fOptions2 then if eoFoldedCopyPaste in fOptions2 then
FInfo := FFoldedLinesView.GetFoldDescription( FInfo := FFoldedLinesView.GetFoldDescription(
FBlockSelection.FirstLineBytePos.Y - 1, FBlockSelection.FirstLineBytePos.X, FBlockSelection.FirstLineBytePos.Y - 1, FBlockSelection.FirstLineBytePos.X,
FBlockSelection.LastLineBytePos.Y - 1, FBlockSelection.LastLineBytePos.X) FBlockSelection.LastLineBytePos.Y - 1, FBlockSelection.LastLineBytePos.X);
else
FInfo := '';
DoCopyToClipboard(SelText, FInfo); DoCopyToClipboard(SelText, FInfo);
end; end;
end; end;
@ -1910,9 +1908,7 @@ begin
if eoFoldedCopyPaste in fOptions2 then if eoFoldedCopyPaste in fOptions2 then
FInfo := FFoldedLinesView.GetFoldDescription( FInfo := FFoldedLinesView.GetFoldDescription(
FBlockSelection.FirstLineBytePos.Y - 1, FBlockSelection.FirstLineBytePos.X, FBlockSelection.FirstLineBytePos.Y - 1, FBlockSelection.FirstLineBytePos.X,
FBlockSelection.LastLineBytePos.Y - 1, FBlockSelection.LastLineBytePos.X) FBlockSelection.LastLineBytePos.Y - 1, FBlockSelection.LastLineBytePos.X);
else
FInfo := '';
DoCopyToClipboard(SelText, FInfo); DoCopyToClipboard(SelText, FInfo);
SetSelTextExternal(''); SetSelTextExternal('');
end; end;

View File

@ -1038,9 +1038,7 @@ begin
CharWidthsArr := FLines.GetPhysicalCharWidths(Pchar(L), length(L), FLinePos-1); CharWidthsArr := FLines.GetPhysicalCharWidths(Pchar(L), length(L), FLinePos-1);
LogLen := Length(CharWidthsArr); LogLen := Length(CharWidthsArr);
if LogLen > 0 then if LogLen > 0 then
CharWidths := @CharWidthsArr[0] CharWidths := @CharWidthsArr[0];
else
CharWidths := nil;
end; end;
ScreenPos := 1; ScreenPos := 1;
@ -1524,7 +1522,8 @@ function TSynEditSelection.GetSelText : string;
end; end;
end; end;
procedure CopyAndForward(const S: string; Index, Count: Integer; var P: PChar); procedure CopyAndForward(const S: string; Index, Count: Integer; var P:
PChar);
var var
pSrc: PChar; pSrc: PChar;
SrcLen: Integer; SrcLen: Integer;
@ -1541,7 +1540,8 @@ function TSynEditSelection.GetSelText : string;
end; end;
end; end;
procedure CopyPaddedAndForward(const S: string; Index, Count: Integer; var P: PChar); procedure CopyPaddedAndForward(const S: string; Index, Count: Integer;
var P: PChar);
var var
OldP: PChar; OldP: PChar;
Len: Integer; Len: Integer;
@ -1563,9 +1563,9 @@ var
Col, Len: array of Integer; Col, Len: array of Integer;
begin begin
Result := ''; if not SelAvail then
if SelAvail then Result := ''
begin else begin
if IsBackwardSel then begin if IsBackwardSel then begin
ColFrom := FEndBytePos; ColFrom := FEndBytePos;
First := FEndLinePos - 1; First := FEndLinePos - 1;
@ -2009,7 +2009,6 @@ var
begin begin
// Insert string at current position // Insert string at current position
Result := 0; Result := 0;
Str := '';
Start := PChar(Value); Start := PChar(Value);
repeat repeat
P := GetEOL(Start); P := GetEOL(Start);
@ -3003,7 +3002,7 @@ begin
if (not FCanPaint) and FIsDrawn then begin if (not FCanPaint) and FIsDrawn then begin
AddAfterPaint([psCleanOld, psRemoveTimer]); AddAfterPaint([psCleanOld, psRemoveTimer]);
FIsDrawn := False; FIsDrawn := False;
exit(False); exit(True);
end; end;
FOwner.PaintTimer.RemoveHandler(@DoTimer); FOwner.PaintTimer.RemoveHandler(@DoTimer);
@ -3014,7 +3013,7 @@ end;
function TSynEditScreenCaretPainterInternal.ShowCaret: Boolean; function TSynEditScreenCaretPainterInternal.ShowCaret: Boolean;
begin begin
if Showing then exit(False); if Showing then exit(True);
inherited ShowCaret; inherited ShowCaret;
Exclude(FState, psRemoveTimer); Exclude(FState, psRemoveTimer);
// Exclude(FState, psCleanOld); // only if not moved // Exclude(FState, psCleanOld); // only if not moved

View File

@ -227,7 +227,6 @@ end;
function TSynGutter.CreatePartList: TSynGutterPartListBase; function TSynGutter.CreatePartList: TSynGutterPartListBase;
begin begin
Result := nil;
case Side of case Side of
gsLeft: gsLeft:
begin begin

View File

@ -494,15 +494,13 @@ var
begin begin
AliasMode := Canvas.AntialiasingMode; AliasMode := Canvas.AntialiasingMode;
Canvas.AntialiasingMode:=amOff; Canvas.AntialiasingMode:=amOff;
OdlCosmetic := False; OdlCosmetic := Canvas.Pen.Cosmetic;
if nsoLostHl in SubType then begin if nsoLostHl in SubType then begin
Canvas.Pen.Style := psDot; Canvas.Pen.Style := psDot;
OdlCosmetic := Canvas.Pen.Cosmetic;
Canvas.Pen.Cosmetic := False; Canvas.Pen.Cosmetic := False;
end; end;
if nsoBlockSel in SubType then begin if nsoBlockSel in SubType then begin
Canvas.Pen.Style := psDash; Canvas.Pen.Style := psDash;
OdlCosmetic := Canvas.Pen.Cosmetic;
Canvas.Pen.Cosmetic := False; Canvas.Pen.Cosmetic := False;
end; end;
Canvas.Rectangle(Rect); Canvas.Rectangle(Rect);

View File

@ -1169,7 +1169,6 @@ begin
else begin else begin
// Find new start of a Scheme // Find new start of a Scheme
NewSearchPos := -1; NewSearchPos := -1;
j := 0;
for i := 0 to Schemes.Count - 1 do begin for i := 0 to Schemes.Count - 1 do begin
TmpSearchPos := Schemes.Items[i].FindStartPosInLine(SearchPos); TmpSearchPos := Schemes.Items[i].FindStartPosInLine(SearchPos);
if (NewSearchPos < 0) or ((TmpSearchPos > 0) and (TmpSearchPos < NewSearchPos)) then begin if (NewSearchPos < 0) or ((TmpSearchPos > 0) and (TmpSearchPos < NewSearchPos)) then begin

View File

@ -3287,13 +3287,7 @@ begin
exit; exit;
if AFilter.FoldGroup in [0, FOLDGROUP_REGION, FOLDGROUP_IFDEF] then if AFilter.FoldGroup in [0, FOLDGROUP_REGION, FOLDGROUP_IFDEF] then
inf := TSynHighlighterPasRangeList(CurrentRanges).PasRangeInfo[ALineIndex] inf := TSynHighlighterPasRangeList(CurrentRanges).PasRangeInfo[ALineIndex];
else begin
inf.EndLevelIfDef := 0;
inf.MinLevelIfDef := 0;
inf.EndLevelRegion := 0;
inf.MinLevelRegion := 0;
end;
if AFilter.FoldGroup in [0, FOLDGROUP_PASCAL] then begin if AFilter.FoldGroup in [0, FOLDGROUP_PASCAL] then begin
// All or Pascal // All or Pascal
@ -3343,13 +3337,7 @@ begin
exit; exit;
if AFilter.FoldGroup in [0, FOLDGROUP_REGION, FOLDGROUP_IFDEF] then if AFilter.FoldGroup in [0, FOLDGROUP_REGION, FOLDGROUP_IFDEF] then
inf := TSynHighlighterPasRangeList(CurrentRanges).PasRangeInfo[ALineIndex] inf := TSynHighlighterPasRangeList(CurrentRanges).PasRangeInfo[ALineIndex];
else begin
inf.EndLevelIfDef := 0;
inf.MinLevelIfDef := 0;
inf.EndLevelRegion := 0;
inf.MinLevelRegion := 0;
end;
if AFilter.FoldGroup in [0, FOLDGROUP_PASCAL] then begin if AFilter.FoldGroup in [0, FOLDGROUP_PASCAL] then begin
// All or Pascal // All or Pascal
@ -3860,9 +3848,7 @@ var
nd: PSynFoldNodeInfo; nd: PSynFoldNodeInfo;
begin begin
if FCatchNodeInfo then if FCatchNodeInfo then
i := FCatchNodeInfoList.CountAll i := FCatchNodeInfoList.CountAll;
else
i := 0;
EndPascalCodeFoldBlock; EndPascalCodeFoldBlock;
if FAtLineStart then begin if FAtLineStart then begin
// If we are not at linestart, new folds could have been opened => handle as normal close // If we are not at linestart, new folds could have been opened => handle as normal close

View File

@ -1582,9 +1582,7 @@ begin
if (y1 < 0) or (y1 > Editor.LinesInWindow + 1) then if (y1 < 0) or (y1 > Editor.LinesInWindow + 1) then
y := -1; // not visible y := -1; // not visible
if y > 1 then if y > 1 then
y2 := Editor.RowToScreenRow(y-1) y2 := Editor.RowToScreenRow(y-1);
else
y2 := 0;
if (y > 0) and (y1 <> y2) or (y=1) then begin if (y > 0) and (y1 <> y2) or (y=1) then begin
if Carets.Visual[Result] = nil then if Carets.Visual[Result] = nil then
@ -1635,9 +1633,7 @@ begin
end; end;
if y > 1 then if y > 1 then
y2 := Editor.RowToScreenRow(y-1) y2 := Editor.RowToScreenRow(y-1);
else
y2 := 0;
if (y1 <> y2) or (y=1) then begin if (y1 <> y2) or (y=1) then begin
if Carets.Visual[i] = nil then if Carets.Visual[i] = nil then