sl@0: /* sl@0: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include "windowslider.h" sl@0: #include "../common/inlines.h" sl@0: sl@0: TWindowSlider::TWindowSlider(const TInteger& aExp, TUint aWindowSize) sl@0: : iExp(aExp), iSize(aWindowSize) sl@0: { sl@0: if(iSize == 0) sl@0: { sl@0: TUint expLen = iExp.BitCount(); sl@0: //These numbers are more or less arbitrary and can be tuned for empirical sl@0: //performance results if desired. It's a trade off between amount of sl@0: //precomputation (more if larger iSize) and number of iterations sl@0: //(more if smaller iSize). The current defaults were obtained sl@0: //from crypto++ sl@0: if( expLen <= 17 ) sl@0: iSize = 1; sl@0: else if( expLen <= 24 ) sl@0: iSize = 2; sl@0: else if( expLen <= 70 ) sl@0: iSize = 3; sl@0: else if( expLen <= 197 ) sl@0: iSize = 4; sl@0: else if( expLen <= 539 ) sl@0: iSize = 5; sl@0: else if( expLen <= 1434 ) sl@0: iSize = 6; sl@0: else sl@0: iSize = 7; sl@0: } sl@0: assert(iSize>=1 && iSize<=7); sl@0: } sl@0: sl@0: void TWindowSlider::FindNextWindow(TUint aBegin) sl@0: { sl@0: assert(iExp.Bit(aBegin)); //initial bit must be 1 sl@0: TInt end = aBegin; sl@0: TUint temp = 0; sl@0: iValue = 0; sl@0: TUint j = 0; sl@0: for(TInt i=aBegin; i>=0 && j>= (WORD_BITS - iLength); sl@0: } sl@0: