]> git.saurik.com Git - wxWidgets.git/commitdiff
No changes, just a small optimization in DataStreamTestCase.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 6 May 2013 00:30:53 +0000 (00:30 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 6 May 2013 00:30:53 +0000 (00:30 +0000)
Don't create streams on the heap completely unnecessarily, just allocate them
on the stack. This makes the code shorter, safer and slightly more efficient.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73935 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

tests/streams/datastreamtest.cpp

index d42dc381c984b119398f646e609c547b7e028150..955d403903f71534b467ad3567324d0ebb802388 100644 (file)
@@ -75,23 +75,19 @@ DataStreamTestCase::DataStreamTestCase()
 static
 wxFloat64 TestFloatRW(wxFloat64 fValue)
 {
-    wxFileOutputStream* pFileOutput = new wxFileOutputStream( wxT("mytext.dat") );
-    wxDataOutputStream* pDataOutput = new wxDataOutputStream( *pFileOutput );
-
-    *pDataOutput << fValue;
+    {
+        wxFileOutputStream pFileOutput( wxT("mytext.dat") );
+        wxDataOutputStream pDataOutput( pFileOutput );
 
-    delete pDataOutput;
-    delete pFileOutput;
+        pDataOutput << fValue;
+    }
 
-    wxFileInputStream* pFileInput = new wxFileInputStream( wxT("mytext.dat") );
-    wxDataInputStream* pDataInput = new wxDataInputStream( *pFileInput );
+    wxFileInputStream pFileInput( wxT("mytext.dat") );
+    wxDataInputStream pDataInput( pFileInput );
 
     wxFloat64 fInFloat;
 
-    *pDataInput >> fInFloat;
-
-    delete pDataInput;
-    delete pFileInput;
+    pDataInput >> fInFloat;
 
     return fInFloat;
 }