Can someone please commit this patch to current cvs?
It will be easier to me to send new patches.
The code is perfectly safe, it basically do nothing :-)
1) mfile.h and mfile.cpp
The patch inlines the Read*Bytes functions avoiding some million calls
2) pbook.cpp
When you start scid (even without a database) an eco file is read that
needs to create 10000 standard board
The change make that clear to the compiler so it will avoid 10000
StdStart() calls.
3) stored.cpp
Solves a bug that leaves storedLineMatches_[line] uninitializated in
some lines.
4) analysis.tcl
Correct the indentation of proc toggleFinishGame.
Thanks.
Index: src/mfile.cpp
===================================================================
RCS file: /cvsroot/scid/scid/src/mfile.cpp,v
retrieving revision 1.11
diff -u -r1.11 mfile.cpp
--- src/mfile.cpp 20 Jan 2010 18:13:27 -0000 1.11
+++ src/mfile.cpp 23 Jan 2011 17:52:42 -0000
@@ -396,17 +396,6 @@
return WriteOneByte (value & 255);
}
-uint
-MFile::ReadTwoBytes ()
-{
- uint result = 0;
- ASSERT (FileMode != FMODE_WriteOnly);
- result = ReadOneByte();
- result <<= 8;
- result += ReadOneByte();
- return result;
-}
-
errorT
MFile::WriteThreeBytes (uint value)
{
@@ -416,19 +405,6 @@
return WriteOneByte (value & 255);
}
-uint
-MFile::ReadThreeBytes ()
-{
- uint result = 0;
- ASSERT (FileMode != FMODE_WriteOnly);
- result = ReadOneByte();
- result <<= 8;
- result += ReadOneByte();
- result <<= 8;
- result += ReadOneByte();
- return result;
-}
-
errorT
MFile::WriteFourBytes (uint value)
{
@@ -439,22 +415,6 @@
return WriteOneByte (value & 255);
}
-
-uint
-MFile::ReadFourBytes ()
-{
- uint result = 0;
- ASSERT (FileMode != FMODE_WriteOnly);
- result = ReadOneByte();
- result <<= 8;
- result += ReadOneByte();
- result <<= 8;
- result += ReadOneByte();
- result <<= 8;
- result += ReadOneByte();
- return result;
-}
-
int
MFile::FillGzBuffer ()
{
Index: src/mfile.h
===================================================================
RCS file: /cvsroot/scid/scid/src/mfile.h,v
retrieving revision 1.4
diff -u -r1.4 mfile.h
--- src/mfile.h 6 Jan 2009 17:31:34 -0000 1.4
+++ src/mfile.h 23 Jan 2011 17:52:42 -0000
@@ -121,9 +121,36 @@
errorT WriteThreeBytes (uint value);
errorT WriteFourBytes (uint value);
inline int ReadOneByte ();
- uint ReadTwoBytes ();
- uint ReadThreeBytes ();
- uint ReadFourBytes ();
+ inline uint ReadTwoBytes ()
+ {
+ ASSERT (FileMode != FMODE_WriteOnly);
+ uint result = ReadOneByte();
+ result <<= 8;
+ result += ReadOneByte();
+ return result;
+ };
+ inline uint ReadThreeBytes ()
+ {
+ ASSERT (FileMode != FMODE_WriteOnly);
+ uint result = ReadOneByte();
+ result <<= 8;
+ result += ReadOneByte();
+ result <<= 8;
+ result += ReadOneByte();
+ return result;
+ }
+ inline uint ReadFourBytes ()
+ {
+ ASSERT (FileMode != FMODE_WriteOnly);
+ uint result = ReadOneByte();
+ result <<= 8;
+ result += ReadOneByte();
+ result <<= 8;
+ result += ReadOneByte();
+ result <<= 8;
+ result += ReadOneByte();
+ return result;
+ }
inline char * GetFileName ();
};
Index: src/pbook.cpp
===================================================================
RCS file: /cvsroot/scid/scid/src/pbook.cpp,v
retrieving revision 1.5
diff -u -r1.5 pbook.cpp
--- src/pbook.cpp 22 Jun 2008 21:46:46 -0000 1.5
+++ src/pbook.cpp 23 Jan 2011 17:52:44 -0000
@@ -501,7 +501,8 @@
ReadOnly = true;
LineCount = 1;
- Position pos;
+ Position std_start;
+ std_start.StdStart();
DString text;
DString moves;
ecoStringT ecoStr;
@@ -579,7 +580,7 @@
}
prev = ch;
}
- pos.StdStart();
+ Position pos (std_start);
err = pos.ReadLine (moves.Data());
if (err != OK) { goto corrupt; }
text.Append ("moves ", strTrimLeft (moves.Data()), "\n");
Index: src/stored.cpp
===================================================================
RCS file: /cvsroot/scid/scid/src/stored.cpp,v
retrieving revision 1.4
diff -u -r1.4 stored.cpp
--- src/stored.cpp 9 Jan 2011 10:29:47 -0000 1.4
+++ src/stored.cpp 23 Jan 2011 17:52:45 -0000
@@ -381,20 +381,19 @@
}
StoredLine::StoredLine(Position* pos) {
- if (storedLineGames == NULL) { Init(); }
-
- for (int line = StoredLine::Count(); line > 0; --line) {
- Game * lineGame = storedLineGames [line];
- lineGame->MoveToPly (0);
- bool never_match = false;
- if (lineGame->ExactMatch (pos, NULL, &storedLineMoves_[line], &never_match)) {
- if (storedLineMoves_[line].from != NULL_SQUARE) {
- storedLineMatches_[line] = lineGame->GetCurrentPly() + 1;
- }
- } else
- if (never_match) storedLineMatches_[line] = -1;
- else storedLineMatches_[line] = 0;
- }
+ if (storedLineGames == NULL) { Init(); }
+ for (int line = StoredLine::Count(); line > 0; --line) {
+ Game * lineGame = storedLineGames [line];
+ lineGame->MoveToPly (0);
+ bool never_match = false;
+ storedLineMatches_[line] = 0;
+ if (lineGame->ExactMatch (pos, NULL, &storedLineMoves_[line], &never_match)) {
+ if (storedLineMoves_[line].from != NULL_SQUARE)
+ storedLineMatches_[line] = lineGame->GetCurrentPly() + 1;
+ } else {
+ if (never_match) storedLineMatches_[line] = -1;
+ }
+ }
}
//////////////////////////////////////////////////////////////////////
Index: tcl/tools/analysis.tcl
===================================================================
RCS file: /cvsroot/scid/scid/tcl/tools/analysis.tcl,v
retrieving revision 1.72
diff -u -r1.72 analysis.tcl
--- tcl/tools/analysis.tcl 9 Jan 2011 10:29:47 -0000 1.72
+++ tcl/tools/analysis.tcl 23 Jan 2011 17:53:05 -0000
@@ -2343,174 +2343,174 @@
# will ask engine(s) to play the game till the end
################################################################################
proc toggleFinishGame { { n 1 } } {
- global analysis
- set b ".analysisWin$n.b1.bFinishGame"
- if { $::annotateModeButtonValue || $::autoplayMode } { return }
- if { ! $analysis(uci$n) } {
- if { !$analysis(analyzeMode$n) || ! [sc_pos isAt vend] } { return }
-
- if {!$::finishGameMode} {
- set ::finishGameMode 1
- $b configure -image finish_on -relief flat
- after $::autoplayDelay autoplayFinishGame
- } else {
- set ::finishGameMode 0
- $b configure -image finish_off -relief flat
- after cancel autoplayFinishGame
- }
- return
- }
-
- if {$::finishGameMode} {
- set ::finishGameMode 0
- sendToEngine 1 "stop"
- set analysis(waitForReadyOk1) 0
- set analysis(waitForBestMove1) 0
- sendToEngine 2 "stop"
- set analysis(waitForReadyOk2) 0
- set analysis(waitForBestMove2) 0
- $b configure -image finish_off -relief flat
- grab release .analysisWin$n
- .analysisWin$n.b1.bStartStop configure -state normal
- .analysisWin$n.b1.move configure -state normal
- .analysisWin$n.b1.line configure -state normal
- .analysisWin$n.b1.alllines configure -state normal
- .analysisWin$n.b1.annotate configure -state normal
- .analysisWin$n.b1.automove configure -state normal
- return
- }
+ global analysis
+ set b ".analysisWin$n.b1.bFinishGame"
+ if { $::annotateModeButtonValue || $::autoplayMode } { return }
+ if { ! $analysis(uci$n) } {
+ if { !$analysis(analyzeMode$n) || ! [sc_pos isAt vend] } { return }
+
+ if {!$::finishGameMode} {
+ set ::finishGameMode 1
+ $b configure -image finish_on -relief flat
+ after $::autoplayDelay autoplayFinishGame
+ } else {
+ set ::finishGameMode 0
+ $b configure -image finish_off -relief flat
+ after cancel autoplayFinishGame
+ }
+ return
+ }
+
+ if {$::finishGameMode} {
+ set ::finishGameMode 0
+ sendToEngine 1 "stop"
+ set analysis(waitForReadyOk1) 0
+ set analysis(waitForBestMove1) 0
+ sendToEngine 2 "stop"
+ set analysis(waitForReadyOk2) 0
+ set analysis(waitForBestMove2) 0
+ $b configure -image finish_off -relief flat
+ grab release .analysisWin$n
+ .analysisWin$n.b1.bStartStop configure -state normal
+ .analysisWin$n.b1.move configure -state normal
+ .analysisWin$n.b1.line configure -state normal
+ .analysisWin$n.b1.alllines configure -state normal
+ .analysisWin$n.b1.annotate configure -state normal
+ .analysisWin$n.b1.automove configure -state normal
+ return
+ }
- set w .configFinishGame
- toplevel $w -class Dialog -bg [ttk::style lookup . -background]
- wm resizable $w 0 0
- ::setTitle $w "Scid: $::tr(FinishGame)"
+ set w .configFinishGame
+ toplevel $w -class Dialog -bg [ttk::style lookup . -background]
+ wm resizable $w 0 0
+ ::setTitle $w "Scid: $::tr(FinishGame)"
- ttk::labelframe $w.wh_f -text "$::tr(White)" -padding 5
- grid $w.wh_f -column 0 -row 0 -columnspan 2 -sticky we -pady 8
- label $w.wh_f.p -image wk$::board::_size(.main.board)
- grid $w.wh_f.p -column 0 -row 0 -rowspan 3
- ttk::radiobutton $w.wh_f.e1 -text $analysis(name1) -variable ::finishGameEng1 -value 1
- if {[winfo exists .analysisWin2] } {
- ttk::radiobutton $w.wh_f.e2 -text $analysis(name2) -variable ::finishGameEng1 -value 2
- } else {
- ttk::radiobutton $w.wh_f.e2 -text $::tr(StartEngine) -variable ::finishGameEng1 -value 2 -state disabled
- }
- grid $w.wh_f.e1 -column 1 -row 0 -columnspan 3 -sticky w
- grid $w.wh_f.e2 -column 1 -row 1 -columnspan 3 -sticky w
- spinbox $w.wh_f.cv -width 4 -textvariable ::finishGameCmdVal1 -from 1 -to 999
- ttk::radiobutton $w.wh_f.c1 -text $::tr(seconds) -variable ::finishGameCmd1 -value "movetime"
- ttk::radiobutton $w.wh_f.c2 -text $::tr(FixedDepth) -variable ::finishGameCmd1 -value "depth"
- grid $w.wh_f.cv -column 1 -row 2 -sticky w
- grid $w.wh_f.c1 -column 2 -row 2 -sticky w
- grid $w.wh_f.c2 -column 3 -row 2 -sticky w
- grid columnconfigure $w.wh_f 2 -weight 1
-
- ttk::labelframe $w.bk_f -text "$::tr(Black)" -padding 5
- grid $w.bk_f -column 0 -row 1 -columnspan 2 -sticky we -pady 8
- label $w.bk_f.p -image bk$::board::_size(.main.board)
- grid $w.bk_f.p -column 0 -row 0 -rowspan 3
- ttk::radiobutton $w.bk_f.e1 -text $analysis(name1) -variable ::finishGameEng2 -value 1
- if {[winfo exists .analysisWin2] } {
- ttk::radiobutton $w.bk_f.e2 -text $analysis(name2) -variable ::finishGameEng2 -value 2
- } else {
- ttk::radiobutton $w.bk_f.e2 -text $::tr(StartEngine) -variable ::finishGameEng2 -value 2 -state disabled
- }
- grid $w.bk_f.e1 -column 1 -row 0 -columnspan 3 -sticky w
- grid $w.bk_f.e2 -column 1 -row 1 -columnspan 3 -sticky w
- spinbox $w.bk_f.cv -width 4 -textvariable ::finishGameCmdVal2 -from 1 -to 999
- ttk::radiobutton $w.bk_f.c1 -text $::tr(seconds) -variable ::finishGameCmd2 -value "movetime"
- ttk::radiobutton $w.bk_f.c2 -text $::tr(FixedDepth) -variable ::finishGameCmd2 -value "depth"
- grid $w.bk_f.cv -column 1 -row 2 -sticky w
- grid $w.bk_f.c1 -column 2 -row 2 -sticky w
- grid $w.bk_f.c2 -column 3 -row 2 -sticky w
- grid columnconfigure $w.bk_f 2 -weight 1
-
- ttk::checkbutton $w.annotate -text $::tr(Annotate) -variable ::finishGameAnnotate
- grid $w.annotate -column 0 -row 2 -columnspan 2 -sticky w -padx 5 -pady 8
-
- ttk::button $w.cancel -text $::tr(Cancel) -command { destroy .configFinishGame }
- grid $w.cancel -column 0 -row 3
- ttk::button $w.ok -text "OK" -command {
- if {$::finishGameEng1 == $::finishGameEng2} {
- set ::finishGameMode 1
- } else {
- set ::finishGameMode 2
- }
- destroy .configFinishGame
- }
- grid $w.ok -column 1 -row 3
- focus $w.ok
- bind $w <Escape> { .configFinishGame.cancel invoke }
- bind $w <Return> { .configFinishGame.ok invoke }
- bind $w <Destroy> { focus .analysisWin1 }
- ::tk::PlaceWindow $w widget .analysisWin1
- grab $w
- bind $w <ButtonPress> {
- set w .configFinishGame
- wm deiconify $w
- if {%x < 0 || %x > [winfo width $w] || %y < 0 || %y > [winfo height $w] } { ::tk::PlaceWindow $w pointer }
- }
- tkwait window $w
- if {!$::finishGameMode} { return }
-
- set gocmd(1) "go $::finishGameCmd1 $::finishGameCmdVal1"
- set gocmd(2) "go $::finishGameCmd2 $::finishGameCmdVal2"
- if {$::finishGameCmd1 == "movetime" } { append gocmd(1) "000" }
- if {$::finishGameCmd2 == "movetime" } { append gocmd(2) "000" }
- if {[sc_pos side] == "white"} {
- set current_cmd 1
- set current_engine $::finishGameEng1
- } else {
- set current_cmd 2
- set current_engine $::finishGameEng2
- }
-
- stopEngineAnalysis 1
- stopEngineAnalysis 2
- $b configure -image finish_on -relief flat
- .analysisWin$n.b1.bStartStop configure -state disabled
- .analysisWin$n.b1.move configure -state disabled
- .analysisWin$n.b1.line configure -state disabled
- .analysisWin$n.b1.alllines configure -state disabled
- .analysisWin$n.b1.annotate configure -state disabled
- .analysisWin$n.b1.automove configure -state disabled
- grab .analysisWin$n
-
- while { [string index [sc_game info previousMove] end] != "#"} {
- set analysis(waitForReadyOk$current_engine) 1
- sendToEngine $current_engine "isready"
- vwait analysis(waitForReadyOk$current_engine)
- if {!$::finishGameMode} { break }
- sendToEngine $current_engine "position fen [sc_pos fen]"
- sendToEngine $current_engine $gocmd($current_cmd)
- set analysis(fen$current_engine) [sc_pos fen]
- set analysis(maxmovenumber$current_engine) 0
- set analysis(waitForBestMove$current_engine) 1
- vwait analysis(waitForBestMove$current_engine)
- if {!$::finishGameMode} { break }
-
- if { ! [sc_pos isAt vend] } { sc_var create }
- if {$::finishGameAnnotate} {
- set moves [ lindex [ lindex $analysis(multiPV$current_engine) 0 ] 2 ]
- set text [format "%+.2f %s - %s Depth: %d Time:%6.2f s" \
- $analysis(score$current_engine) \
- [addMoveNumbers $current_engine [::trans $moves]] \
- $analysis(name$current_engine) \
- $analysis(depth$current_engine) \
- $analysis(time$current_engine) ]
- makeAnalysisMove $current_engine $text
- } else {
- makeAnalysisMove $current_engine
- }
+ ttk::labelframe $w.wh_f -text "$::tr(White)" -padding 5
+ grid $w.wh_f -column 0 -row 0 -columnspan 2 -sticky we -pady 8
+ label $w.wh_f.p -image wk$::board::_size(.main.board)
+ grid $w.wh_f.p -column 0 -row 0 -rowspan 3
+ ttk::radiobutton $w.wh_f.e1 -text $analysis(name1) -variable ::finishGameEng1 -value 1
+ if {[winfo exists .analysisWin2] } {
+ ttk::radiobutton $w.wh_f.e2 -text $analysis(name2) -variable ::finishGameEng1 -value 2
+ } else {
+ ttk::radiobutton $w.wh_f.e2 -text $::tr(StartEngine) -variable ::finishGameEng1 -value 2 -state disabled
+ }
+ grid $w.wh_f.e1 -column 1 -row 0 -columnspan 3 -sticky w
+ grid $w.wh_f.e2 -column 1 -row 1 -columnspan 3 -sticky w
+ spinbox $w.wh_f.cv -width 4 -textvariable ::finishGameCmdVal1 -from 1 -to 999
+ ttk::radiobutton $w.wh_f.c1 -text $::tr(seconds) -variable ::finishGameCmd1 -value "movetime"
+ ttk::radiobutton $w.wh_f.c2 -text $::tr(FixedDepth) -variable ::finishGameCmd1 -value "depth"
+ grid $w.wh_f.cv -column 1 -row 2 -sticky w
+ grid $w.wh_f.c1 -column 2 -row 2 -sticky w
+ grid $w.wh_f.c2 -column 3 -row 2 -sticky w
+ grid columnconfigure $w.wh_f 2 -weight 1
+
+ ttk::labelframe $w.bk_f -text "$::tr(Black)" -padding 5
+ grid $w.bk_f -column 0 -row 1 -columnspan 2 -sticky we -pady 8
+ label $w.bk_f.p -image bk$::board::_size(.main.board)
+ grid $w.bk_f.p -column 0 -row 0 -rowspan 3
+ ttk::radiobutton $w.bk_f.e1 -text $analysis(name1) -variable ::finishGameEng2 -value 1
+ if {[winfo exists .analysisWin2] } {
+ ttk::radiobutton $w.bk_f.e2 -text $analysis(name2) -variable ::finishGameEng2 -value 2
+ } else {
+ ttk::radiobutton $w.bk_f.e2 -text $::tr(StartEngine) -variable ::finishGameEng2 -value 2 -state disabled
+ }
+ grid $w.bk_f.e1 -column 1 -row 0 -columnspan 3 -sticky w
+ grid $w.bk_f.e2 -column 1 -row 1 -columnspan 3 -sticky w
+ spinbox $w.bk_f.cv -width 4 -textvariable ::finishGameCmdVal2 -from 1 -to 999
+ ttk::radiobutton $w.bk_f.c1 -text $::tr(seconds) -variable ::finishGameCmd2 -value "movetime"
+ ttk::radiobutton $w.bk_f.c2 -text $::tr(FixedDepth) -variable ::finishGameCmd2 -value "depth"
+ grid $w.bk_f.cv -column 1 -row 2 -sticky w
+ grid $w.bk_f.c1 -column 2 -row 2 -sticky w
+ grid $w.bk_f.c2 -column 3 -row 2 -sticky w
+ grid columnconfigure $w.bk_f 2 -weight 1
+
+ ttk::checkbutton $w.annotate -text $::tr(Annotate) -variable ::finishGameAnnotate
+ grid $w.annotate -column 0 -row 2 -columnspan 2 -sticky w -padx 5 -pady 8
+
+ ttk::button $w.cancel -text $::tr(Cancel) -command { destroy .configFinishGame }
+ grid $w.cancel -column 0 -row 3
+ ttk::button $w.ok -text "OK" -command {
+ if {$::finishGameEng1 == $::finishGameEng2} {
+ set ::finishGameMode 1
+ } else {
+ set ::finishGameMode 2
+ }
+ destroy .configFinishGame
+ }
+ grid $w.ok -column 1 -row 3
+ focus $w.ok
+ bind $w <Escape> { .configFinishGame.cancel invoke }
+ bind $w <Return> { .configFinishGame.ok invoke }
+ bind $w <Destroy> { focus .analysisWin1 }
+ ::tk::PlaceWindow $w widget .analysisWin1
+ grab $w
+ bind $w <ButtonPress> {
+ set w .configFinishGame
+ wm deiconify $w
+ if {%x < 0 || %x > [winfo width $w] || %y < 0 || %y > [winfo height $w] } { ::tk::PlaceWindow $w pointer }
+ }
+ tkwait window $w
+ if {!$::finishGameMode} { return }
+
+ set gocmd(1) "go $::finishGameCmd1 $::finishGameCmdVal1"
+ set gocmd(2) "go $::finishGameCmd2 $::finishGameCmdVal2"
+ if {$::finishGameCmd1 == "movetime" } { append gocmd(1) "000" }
+ if {$::finishGameCmd2 == "movetime" } { append gocmd(2) "000" }
+ if {[sc_pos side] == "white"} {
+ set current_cmd 1
+ set current_engine $::finishGameEng1
+ } else {
+ set current_cmd 2
+ set current_engine $::finishGameEng2
+ }
+
+ stopEngineAnalysis 1
+ stopEngineAnalysis 2
+ $b configure -image finish_on -relief flat
+ .analysisWin$n.b1.bStartStop configure -state disabled
+ .analysisWin$n.b1.move configure -state disabled
+ .analysisWin$n.b1.line configure -state disabled
+ .analysisWin$n.b1.alllines configure -state disabled
+ .analysisWin$n.b1.annotate configure -state disabled
+ .analysisWin$n.b1.automove configure -state disabled
+ grab .analysisWin$n
+
+ while { [string index [sc_game info previousMove] end] != "#"} {
+ set analysis(waitForReadyOk$current_engine) 1
+ sendToEngine $current_engine "isready"
+ vwait analysis(waitForReadyOk$current_engine)
+ if {!$::finishGameMode} { break }
+ sendToEngine $current_engine "position fen [sc_pos fen]"
+ sendToEngine $current_engine $gocmd($current_cmd)
+ set analysis(fen$current_engine) [sc_pos fen]
+ set analysis(maxmovenumber$current_engine) 0
+ set analysis(waitForBestMove$current_engine) 1
+ vwait analysis(waitForBestMove$current_engine)
+ if {!$::finishGameMode} { break }
+
+ if { ! [sc_pos isAt vend] } { sc_var create }
+ if {$::finishGameAnnotate} {
+ set moves [ lindex [ lindex $analysis(multiPV$current_engine) 0 ] 2 ]
+ set text [format "%+.2f %s - %s Depth: %d Time:%6.2f s" \
+ $analysis(score$current_engine) \
+ [addMoveNumbers $current_engine [::trans $moves]] \
+ $analysis(name$current_engine) \
+ $analysis(depth$current_engine) \
+ $analysis(time$current_engine) ]
+ makeAnalysisMove $current_engine $text
+ } else {
+ makeAnalysisMove $current_engine
+ }
- incr current_cmd
- if {$current_cmd > 2} { set current_cmd 1 }
- if {$::finishGameMode == 2} {
- incr current_engine
- if {$current_engine > 2 } { set current_engine 1 }
- }
- }
- if {$::finishGameMode} { toggleFinishGame }
+ incr current_cmd
+ if {$current_cmd > 2} { set current_cmd 1 }
+ if {$::finishGameMode == 2} {
+ incr current_engine
+ if {$current_engine > 2 } { set current_engine 1 }
+ }
+ }
+ if {$::finishGameMode} { toggleFinishGame }
}
################################################################################
#
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Scid-users mailing list
Scid-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scid-users