shithub: mc

Download patch

ref: 55f9f36fd0a2dd5378f1a71a82aa9eb1b7f69562
parent: 82b14a44660222bab4c91275faa409bd224718fd
author: Ori Bernstein <[email protected]>
date: Sat Dec 28 11:52:12 EST 2013

Move towards using 'for in' loops.

--- a/libstd/env.myr
+++ b/libstd/env.myr
@@ -9,13 +9,11 @@
 ;;
 
 const getenv = {name
-	var i
-
 	var n
-	for i = 0; i < _environment.len; i++
-		n = min(name.len, _environment[i].len)
-		if sleq(name, _environment[i][:n]) && sleq(_environment[i][n:n+1], "=")
-			-> `Some _environment[i][n+1:]
+	for env in _environment
+		n = min(name.len, env.len)
+		if sleq(name, env[:n]) && sleq(env[n:n+1], "=")
+			-> `Some env[n+1:]
 		;;
 	;;
 	-> `None
--- a/libstd/hashfuncs.myr
+++ b/libstd/hashfuncs.myr
@@ -15,11 +15,10 @@
 /* Supremely simple djb hash. */
 const strhash = {s
 	var h
-	var i
 	
 	h = 5381
-	for i = 0; i < s.len; i++
-		h = (h << 5) + h + (s[i] castto(uint32))
+	for b in s
+		h = (h << 5) + h + (b castto(uint32))
 	;;
 	-> h
 }