public Size GetSize(int key, out bool found) { object obj2 = this.GetObject(key, out found); if (found) { SizeWrapper wrapper = obj2 as SizeWrapper; if (wrapper != null) { return(wrapper.Size); } } found = false; return(Size.Empty); }
// this is a wrapper around GetObject designed to // reduce the boxing hit public Size GetSize(int key, out bool found) { object storedObject = GetObject(key, out found); if (found) { SizeWrapper wrapper = storedObject as SizeWrapper; if (wrapper != null) { return(wrapper.Size); } #if DEBUG else if (storedObject != null) { Debug.Fail("Have non-null object that isnt a padding wrapper stored in a padding entry!\r\nDid someone SetObject instead of SetPadding?"); } #endif } // we didnt actually find a non-null size wrapper. found = false; return(Size.Empty); }
public void SetSize(int key, Size value) { bool flag; object obj2 = this.GetObject(key, out flag); if (!flag) { this.SetObject(key, new SizeWrapper(value)); } else { SizeWrapper wrapper = obj2 as SizeWrapper; if (wrapper != null) { wrapper.Size = value; } else { this.SetObject(key, new SizeWrapper(value)); } } }
public void SetSize(int key, Size value) { bool found; object storedObject = GetObject(key, out found); if (!found) { SetObject(key, new SizeWrapper(value)); } else { SizeWrapper wrapper = storedObject as SizeWrapper; if (wrapper != null) { // re-using the wrapper reduces the boxing hit. wrapper.Size = value; } else { Debug.Assert(storedObject == null, "object should either be null or SizeWrapper"); // could someone have SetObject to this key behind our backs? SetObject(key, new SizeWrapper(value)); } } }