RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Shortening of code

milt

Knight
Shortening of code

Was bored looking through some RunUO core code the other night and noticed the following inside of Poin3DList.cs:

Code:
public void Add( int x, int y, int z )
		{
			if ( (m_Count + 1) > m_List.Length )
			{
				Point3D[] old = m_List;
				m_List = new Point3D[old.Length * 2];

				for ( int i = 0; i < old.Length; ++i )
					m_List[i] = old[i];
			}

			m_List[m_Count].m_X = x;
			m_List[m_Count].m_Y = y;
			m_List[m_Count].m_Z = z;
			++m_Count;
		}

		public void Add( Point3D p )
		{
			if ( (m_Count + 1) > m_List.Length )
			{
				Point3D[] old = m_List;
				m_List = new Point3D[old.Length * 2];

				for ( int i = 0; i < old.Length; ++i )
					m_List[i] = old[i];
			}

			m_List[m_Count].m_X = p.m_X;
			m_List[m_Count].m_Y = p.m_Y;
			m_List[m_Count].m_Z = p.m_Z;
			++m_Count;
		}
Wouldn't it have been much simpler to have just put the following for the second overload? (Point3D)

Code:
public void Add( Point3D p )
		{
			Add( p.X, p.Y, p.Z );
		}
I know that it is not a bug and it works fine, but just decided to post this in case you wanted to shorten the code a bit.
 
Top