@@ -936,20 +936,14 @@ impl<'conn> Drop for PostgresTransaction<'conn> {
936936
937937impl < ' conn > PostgresTransaction < ' conn > {
938938 fn finish_inner ( & mut self ) -> PostgresResult < ( ) > {
939- if task:: failing ( ) || !self . commit . get ( ) {
940- if self . nested {
941- try!( self . conn . quick_query ( "ROLLBACK TO sp" ) ) ;
942- } else {
943- try!( self . conn . quick_query ( "ROLLBACK" ) ) ;
944- }
945- } else {
946- if self . nested {
947- try!( self . conn . quick_query ( "RELEASE sp" ) ) ;
948- } else {
949- try!( self . conn . quick_query ( "COMMIT" ) ) ;
950- }
951- }
952- Ok ( ( ) )
939+ let rollback = task:: failing ( ) || !self . commit . get ( ) ;
940+ let query = match ( rollback, self . nested ) {
941+ ( true , true ) => "ROLLBACK TO sp" ,
942+ ( true , false ) => "ROLLBACK" ,
943+ ( false , true ) => "RELEASE sp" ,
944+ ( false , false ) => "COMMIT" ,
945+ } ;
946+ self . conn . quick_query ( query) . map ( |_| ( ) )
953947 }
954948
955949 /// Like `PostgresConnection::prepare`.
@@ -1317,7 +1311,6 @@ impl<'stmt> PostgresRows<'stmt> {
13171311 ///
13181312 /// Functionally identical to the `Drop` implementation on `PostgresRows`
13191313 /// except that it returns any error to the caller.
1320- #[ inline]
13211314 pub fn finish ( mut self ) -> PostgresResult < ( ) > {
13221315 self . finished = true ;
13231316 self . finish_inner ( )
@@ -1452,6 +1445,7 @@ impl RowIndex for int {
14521445}
14531446
14541447impl < ' a > RowIndex for & ' a str {
1448+ #[ inline]
14551449 fn idx ( & self , stmt : & PostgresStatement ) -> Option < uint > {
14561450 for ( i, desc) in stmt. result_descriptions ( ) . iter ( ) . enumerate ( ) {
14571451 if desc. name . as_slice ( ) == * self {
0 commit comments