Patch #1164 2006-06-26 19:08

sethjackson

main.cpp cleanup
Download
1164-main_cpp_clean.patch (3.1 KB)
Category
Application::Refinement
Status
Closed
Close date
2006-06-28 19:26
Assigned to
 
Index: src/src/main.cpp
===================================================================
--- src/src/main.cpp    (revision 2613)
+++ src/src/main.cpp    (working copy)
@@ -1461,7 +1461,7 @@
     }
     else
         links << _T("&nbsp;&nbsp;&nbsp;&nbsp;No recent projects<br>\n");
-    
+
     links << _T("<br><b>Recent files</b><br>\n");
     if (m_FilesHistory.GetCount())
     {
@@ -2134,15 +2134,17 @@
 void MainFrame::OnEditCommentSelected(wxCommandEvent& event)
 {
     cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
-    if( ed )
+    if(ed)
     {
-        ed->GetControl()->BeginUndoAction();
-        cbStyledTextCtrl *stc = ed->GetControl();
-        if( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
+        cbStyledTextCtrl* stc = ed->GetControl();
+
+        stc->BeginUndoAction();
+
+        if(stc->GetSelectionStart() != wxSCI_INVALID_POSITION)
         {
             int startLine = stc->LineFromPosition( stc->GetSelectionStart() );
             int endLine   = stc->LineFromPosition( stc->GetSelectionEnd() );
-            wxString strLine, str;
+            wxString strLine;
 
             /**
                 Fix a glitch: when selecting multiple lines and the caret
@@ -2170,7 +2172,8 @@
                 startLine++;
             }
         }
-        ed->GetControl()->EndUndoAction();
+
+        stc->EndUndoAction();
     }
 }
 
@@ -2178,15 +2181,17 @@
 void MainFrame::OnEditUncommentSelected(wxCommandEvent& event)
 {
     cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
-    if( ed )
+    if(ed)
     {
-        ed->GetControl()->BeginUndoAction();
-        cbStyledTextCtrl *stc = ed->GetControl();
-        if( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
+        cbStyledTextCtrl* stc = ed->GetControl();
+
+        stc->BeginUndoAction();
+
+        if(stc->GetSelectionStart() != wxSCI_INVALID_POSITION)
         {
             int startLine = stc->LineFromPosition( stc->GetSelectionStart() );
             int endLine   = stc->LineFromPosition( stc->GetSelectionEnd() );
-            wxString strLine, str;
+            wxString strLine;
 
             /**
                 Fix a glitch: when selecting multiple lines and the caret
@@ -2224,22 +2229,25 @@
                 startLine++;
             }
         }
-        ed->GetControl()->EndUndoAction();
+
+        stc->EndUndoAction();
     }
-} // end of OnEditUncommentSelected
+}
 
 void MainFrame::OnEditToggleCommentSelected(wxCommandEvent& event)
 {
     cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
-    if( ed )
+    if(ed)
     {
-        ed->GetControl()->BeginUndoAction();
-        cbStyledTextCtrl *stc = ed->GetControl();
-        if( wxSCI_INVALID_POSITION != stc->GetSelectionStart() )
+        cbStyledTextCtrl* stc = ed->GetControl();
+
+        stc->BeginUndoAction();
+
+        if(stc->GetSelectionStart() != wxSCI_INVALID_POSITION)
         {
             int startLine = stc->LineFromPosition( stc->GetSelectionStart() );
             int endLine   = stc->LineFromPosition( stc->GetSelectionEnd() );
-            wxString strLine, str;
+            wxString strLine;
 
             /**
                 Fix a glitch: when selecting multiple lines and the caret
@@ -2284,9 +2292,10 @@
                 startLine++;
             }
         }
-        ed->GetControl()->EndUndoAction();
+
+        stc->EndUndoAction();
     }
-} // end of OnEditToggleCommentSelected
+}
 
 void MainFrame::OnEditAutoComplete(wxCommandEvent& event)
 {
sethjackson 2006-06-26 19:11

This patch doesn't really change much. Since the code got a cbStyledTextCtrl I though it would be better to do it at the start of the function, and then use stc-> throughout the code. I also removed an unsed variable. :)

killerbot 2006-06-28 19:26

due to a bugfix, that code has been changed and cleaned in the meantime, even one more variable could be removed or moved.

So you can consider either the patch to be obsolete or kind of applied ;-)