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

Ben Maurer bmaurer at ximian.com
Sun Jan 22 14:57:51 EST 2006


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
> 




More information about the Mono-devel-list mailing list