dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[DotGNU]what do you think


From: Neil Cawse
Subject: [DotGNU]what do you think
Date: Sun, 18 Jul 2004 11:09:14 -0400

What do you think about reducing the instance size doing this:

        private BitVector32 flags = new BitVector32();

        private const int AcceptsTabFlag = 0x00;
        private const int AutoSizeFlag = 0x01;
        private const int HideSelectionFlag = 0x02;
        private const int ModifiedFlag = 0x04;
        private const int MultilineFlag = 0x08;
        private const int ReadOnlyFlag = 0x0F;
        private const int WordWrapFlag = 0x10;
        private const int InsertModeFlag = 0x20;


        // Constructor.
        internal TextBoxBase() : base()
                        {
                                flags[AutoSizeFlag | HideSelectionFlag |
WordWrapFlag | InsertModeFlag] = true;
                                ...
                        }

        // Get or set this object's properties.
        public bool AcceptsTab
                        {
                                get
                                {
                                        return flags[AcceptsTabFlag];
                                }
                                set
                                {
                                        if (flags[AcceptsTabFlag] !=
value)
                                        {
                                                flags[AcceptsTabFlag] =
value;
        
OnAcceptsTabChanged(EventArgs.Empty);
                                        }
                                }
                        }

I was thinking about putting it into Control where we have lots of bit
fields too. Its probably not necessary on all controls.
In this example we save 28 bytes but it will be more for Control.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]