Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Simple Particle Engine for a shooter game
Snake / Nibbles clone in C and Ncurses
Please improve
Parsing of XML data has high CPU usage
Convert simple Javascript to jQuery plugin
Active Record getting unique records
List the files in a directory without the directory name or the extension
clean the code
ohs system, recruitment software, hr software, oh&s software, human resources software, ohs software
Array parsing in a block
Popular
Parsing of XML data has high CPU usage
Please improve
Snake / Nibbles clone in C and Ncurses
List the files in a directory without the directory name or the extension
Convert simple Javascript to jQuery plugin
Simple Particle Engine for a shooter game
Active Record getting unique records
Breadth first cartesian product iterator
php refactoring
first BST
Pastable version of
Line splitting optimization
<pre class='prettyprint' language='cs'>private static void Log(object message, MessageType type) { string str = message.ToString(); //Handle newlines if (str.IndexOf('\n') >= 0) { foreach (string s in str.Split('\n')) Log(s, type); return; } //Split the string recursively in smaller strings to fit the console window for (int i = str.Length; i > 0; i--) //TODO: Optimize, adding a message of 1000 characters takes too long { if (MessageFits(str.Substring(0, i))) { messages.Add(new Message(str.Substring(0, i), type)); //If user was already all scrolled down, keep him scrolled down if (shownMessage == messages.Count - 2) shownMessage = messages.Count - 1; Log(str.Substring(i), type); //Recursive call to handle the rest break; } } } private static bool MessageFits(string message) { return font.MeasureString(message).X <= window.ClientBounds.Width - (padding * 2) - scrollBarWidth; }</pre> <a href="http://www.refactormycode.com/codes/1122-line-splitting-optimization" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>