Changeset 7ab9c17 in github


Ignore:
Timestamp:
Jun 26, 2012 5:11:53 AM (11 months ago)
Author:
Aleksander Machniak <alec@…>
Branches:
master, HEAD
Children:
0be8bd1, e742744
Parents:
d86aa13
Message:

Improve performance by skipping redundant ENABLE commands

Location:
program/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_imap_cache.php

    r7eb4f2e r7ab9c17  
    918918        } 
    919919 
    920         // NOTE: make sure the mailbox isn't selected, before 
    921         // enabling QRESYNC and invoking SELECT 
    922         if ($this->imap->conn->selected !== null) { 
    923             $this->imap->conn->close(); 
    924         } 
    925  
    926920        // Enable QRESYNC 
    927921        $res = $this->imap->conn->enable($qresync ? 'QRESYNC' : 'CONDSTORE'); 
    928         if (!is_array($res)) { 
     922        if ($res === false) { 
    929923            return; 
     924        } 
     925 
     926        // Close mailbox if already selected to get most recent data 
     927        if ($this->imap->conn->selected == $mailbox) { 
     928            $this->imap->conn->close(); 
    930929        } 
    931930 
  • program/include/rcube_imap_generic.php

    r43918dd2 r7ab9c17  
    14731473    function enable($extension) 
    14741474    { 
    1475         if (empty($extension)) 
    1476             return false; 
    1477  
    1478         if (!$this->hasCapability('ENABLE')) 
    1479             return false; 
    1480  
    1481         if (!is_array($extension)) 
     1475        if (empty($extension)) { 
     1476            return false; 
     1477        } 
     1478 
     1479        if (!$this->hasCapability('ENABLE')) { 
     1480            return false; 
     1481        } 
     1482 
     1483        if (!is_array($extension)) { 
    14821484            $extension = array($extension); 
     1485        } 
     1486 
     1487        if (!empty($this->extensions_enabled)) { 
     1488            // check if all extensions are already enabled 
     1489            $diff = array_diff($extension, $this->extensions_enabled); 
     1490 
     1491            if (empty($diff)) { 
     1492                return $extension; 
     1493            } 
     1494 
     1495            // Make sure the mailbox isn't selected, before enabling extension(s) 
     1496            if ($this->selected !== null) { 
     1497                $this->close(); 
     1498            } 
     1499        } 
    14831500 
    14841501        list($code, $response) = $this->execute('ENABLE', $extension); 
     
    14881505            $result   = (array) $this->tokenizeResponse($response); 
    14891506 
    1490             return $result; 
     1507            $this->extensions_enabled = array_unique(array_merge((array)$this->extensions_enabled, $result)); 
     1508 
     1509            return $this->extensions_enabled; 
    14911510        } 
    14921511 
Note: See TracChangeset for help on using the changeset viewer.