[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: branches/KDE/3.5/kdelibs/kate/part
From:       "Guillermo A. Amaral" <me () guillermoamaral ! com>
Date:       2007-06-18 17:38:32
Message-ID: 200706181038.35271.me () guillermoamaral ! com
[Download RAW message or body]


On Monday 18 June 2007, Leo Savernik wrote:

> Ah, these strange oneEqualToSeven means actually bit position one in
> pattern equals bit position seven in pattern. This is still not self
> explaining. Can't you have a more elaborate name like
> lastUndoGroupWhenSavedEqualsUndoItemsLast?
> And I don't understand why you reference at most 4 bits when you actually
> store eight bits in pattern? Is it because they may be used in the future?
>
> I at least suggest that you put your explanation as a comment to the code
> such that future committers are not left totally stunned. Not everyone used
> to work as an algorithms specialist ;-)
>
> mfg
> 	Leo

Leo,

	Nice. Yes you are absolutely right, I will modify it to make it a bit more 
self explanatory. 

	Here is what happends.

	the pattern starts out empty ( pattern = 0 )

	The 8 toggle bits that are actually used are these:

	1 	if (lastUndoGroupWhenSaved) pattern |= 1;
	2	if (lastRedoGroupWhenSaved) pattern |= 2;
	3	if (docWasSavedWhenUndoWasEmpty) pattern |= 4;
	4	if (docWasSavedWhenRedoWasEmpty) pattern |= 8;
	5	if (undoItems.isEmpty()) pattern |= 16;
	6	if (redoItems.isEmpty()) pattern |= 32;
	7	if (undoItems.last()) pattern |= 64;
	8	if (redoItems.last()) pattern |= 128;

	Put together will give you a unique value depending on what's "True".

	for Example 10000001 will be pattern = 129

	And as an extra fault prevention method I noticed that some pointers are the 
same in certain situations:

	const bool oneEqualToSeven = (lastUndoGroupWhenSaved == undoItems.last());
	const bool oneEqualToEight = (lastUndoGroupWhenSaved == redoItems.last());
	const bool twoEqualToSeven = (lastRedoGroupWhenSaved == undoItems.last());
	const bool twoEqualToEight = (lastRedoGroupWhenSaved == redoItems.last());

	A pattern number might in theory be the same in different scenarios but it's 
really unlikely that the extra xEqualToY will also match.

	I will soften up the code as soon as I get some breakfast in me ^_^ but thats 
it in a nut shell.
	
Take care,
GA

-- 
Guillermo A. Amaral, CSE
# Free & Open Source Advocate
& nick: guillermoamaral
@ blog: http://blog.guillermoamaral.com/
@ site: http://www.guillermoamaral.com/
$ irc: guillermoamaral@freenode
% gpg: http://downloads.guillermoamaral.com/public.asc

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic