[Mono-dev] Re: [Mono-patches] r55711 -trunk/mcs/class/System.Web/System.Web.UI

Ben Maurer bmaurer at ximian.com
Tue Jan 24 13:13:25 EST 2006


I doubt there are enough uses of Color.Empty to justify a 3rd opcode.
Actually, the best use of a 3rd opcode would be for colors that have 100%
alpha (which is the case for most color values from s.web).

Use the method I suggested in the previous value (choose a knowncolor to
use as a flag and if the knowncolor is that value, use one extra bool to
disambig. Or you could even use the -1 knowncolor).

-- Ben

> Please review the reworked patch.
>
> Regards,
> Konstantin Triger
>
>
> -----Original Message-----
> From: mono-devel-list-bounces at lists.ximian.com
> [mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of Ben
> Maurer
> Sent: Sunday, January 22, 2006 9:58 PM
> To: mono-devel-list at lists.ximian.com
> Subject: [Mono-dev] Re: [Mono-patches] r55711
> -trunk/mcs/class/System.Web/System.Web.UI
>
> Hey,
>
> I think this patch adds more bytes than needed to the serialization. An
> easy way of saving a few bytes would be to make Empty a sort of known
> color. So if the known color that was written out was 0, we would then
> write an additional byte to disambig. between known color 0 and empty.
>
> -- Ben
>
> On Wed, 2006-01-18 at 03:57 -0500, Konstantin Triger
> (kostat at mainsoft.com) wrote:
>> Author: kostat
>> Date: 2006-01-18 03:57:28 -0500 (Wed, 18 Jan 2006)
>> New Revision: 55711
>>
>> Modified:
>>    trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
>>    trunk/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs
>> Log:
>> preserve emptiness in ColorFormatter
>>
>> Modified: trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
>> ==================================================================>
>> --- trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
> 2006-01-18 08:51:22 UTC (rev 55710)
>> +++ trunk/mcs/class/System.Web/System.Web.UI/ChangeLog
> 2006-01-18 08:57:28 UTC (rev 55711)
>> @@ -1,5 +1,9 @@
>>  2006-01-18 Konstantin Triger <kostat at mainsoft.com>
>>
>> +	* ObjectStateFormatter.cs: preserve emptiness in ColorFormatter. +
>> +2006-01-18 Konstantin Triger <kostat at mainsoft.com>
>> +
>>  	* HtmlTextWriter.cs: perform case insensitive compare;
>>  	  return correct key in default case.
>>
>>
>> Modified:
> trunk/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs
>> ==================================================================>
>> --- trunk/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs
> 2006-01-18 08:51:22 UTC (rev 55710)
>> +++ trunk/mcs/class/System.Web/System.Web.UI/ObjectStateFormatter.cs
> 2006-01-18 08:57:28 UTC (rev 55711)
>> @@ -663,19 +663,24 @@
>>
>>  				if (!c.IsKnownColor) {
>>  					w.Write (PrimaryId);
>> -					w.Write (c.ToArgb ());
>> +					w.Write(c.IsEmpty);
>> +					if (!c.IsEmpty)
>> +						w.Write (c.ToArgb ());
>>  				} else {
>>  					w.Write (SecondaryId);
>> -					w.Write ((int) c.ToKnownColor
> ());
>> +					w.Write(c.IsEmpty);
>> +					if (!c.IsEmpty)
>> +						w.Write ((int)
> c.ToKnownColor ());
>>  				}
>>  			}
>>
>>  			protected override object Read (byte token,
> BinaryReader r, ReaderContext ctx)
>>  			{
>> +				bool isEmpty = r.ReadBoolean();
>>  				if (token == PrimaryId)
>> -					return Color.FromArgb
> (r.ReadInt32 ());
>> +					return isEmpty ? Color.Empty :
> Color.FromArgb (r.ReadInt32 ());
>>  				else
>> -					return Color.FromKnownColor
> ((KnownColor) r.ReadInt32 ());
>> +					return isEmpty ? Color.Empty :
> Color.FromKnownColor ((KnownColor) r.ReadInt32 ());
>>  			}
>>
>>  			protected override Type Type {
>>
>> _______________________________________________
>> Mono-patches maillist  -  Mono-patches at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-patches
>>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list






More information about the Mono-devel-list mailing list