Skip to content

Commit

Permalink
-50 octets gained by removing Camping::Apps.
Browse files Browse the repository at this point in the history
Camping::Apps was only used by camping/db.rb. The array would also get filled
on each app reload, thus preventing the garbage collection of the old version.
  • Loading branch information
Jonas Pfenniger committed Sep 23, 2007
1 parent 5093efa commit da3ed28
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions lib/camping-unabridged.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ module Camping
# Camping.goes :Tepee
# Camping::Apps # => [Blog, Tepee]
#
Apps = []
C = self
S = IO.read(__FILE__).sub(/^ S = I.+$/,'')
P="Cam\ping Problem!"
Expand Down Expand Up @@ -612,7 +611,7 @@ class << self
# module Blog::Views; ... end
#
def goes(m)
eval S.gsub(/Camping/,m.to_s).gsub("A\pps = []","Cam\ping::Apps<<self"), TOPLEVEL_BINDING
eval S.gsub(/Camping/,m.to_s), TOPLEVEL_BINDING
end
# URL escapes a string.
Expand Down
6 changes: 3 additions & 3 deletions lib/camping.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%w[active_support markaby tempfile uri].map{|l|require l}
module Camping;Apps=[];C=self;S=IO.read(__FILE__).sub(/S=I.+$/,'')
module Camping;C=self;S=IO.read(__FILE__).sub(/S=I.+$/,'')
P="Cam\ping Problem!";module Helpers;def R(c,*g);p,h=/\(.+?\)/,g.grep(Hash)
(g-=h).inject(c.urls.find{|x|x.scan(p).size==g.size}.dup){|s,a|s.sub p,C.
escape((a[a.class.primary_key]rescue a))}+(h.any?? "?"+h[0].map{|x|x.map{|z|C.
Expand Down Expand Up @@ -35,8 +35,8 @@ def redirect*a;r 302,'','Location'=>URL(*a)end;Z="\r\n";def to_a;[@status,@body,
end;class NotFound<R();def get p;r(404,Mab.new{h1 P;h2 p+" not found"})end end
class ServerError<R();def get k,m,e;r(500,Mab.new{h1 P;h2"#{k}.#{m}";h3"#{e.class
} #{e.message}:";ul{e.backtrace.each{|bt|li(bt)}}}.to_s)end end;self;end;class<<
self;def goes m;eval S.gsub(/Camping/,m.to_s).gsub("A\pps=[]","Cam\ping::Apps<<\
self"),TOPLEVEL_BINDING;end;def escape s;s.to_s.gsub(/[^ \w.-]+/n){'%'+($&.
self;def goes m;eval S.gsub(/Camping/,m.to_s),TOPLEVEL_BINDING;end;def escape s
s.to_s.gsub(/[^ \w.-]+/n){'%'+($&.
unpack('H2'*$&.size)*'%').upcase}.tr(' ','+')end;def un s;s.tr('+',' ').gsub(
/%([\da-f]{2})/in){[$1].pack('H*')}end;def qsp q,d='&;',y=nil,z=H[];m=proc{|_,o,n|o.u(
n,&m)rescue([*o]<<n)};q.to_s.split(/[#{d}]+ */n).inject((b,z=z,H[])[0]){|h,p|k,v=un(p).
Expand Down
8 changes: 4 additions & 4 deletions lib/camping/db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def Base.table_name_prefix
module_eval $AR_EXTRAS
end
end
Camping::S.sub! "autoload:Base,'camping/db'", ""
Camping::S.sub! "def Y;self;end", $AR_EXTRAS
Camping::Apps.each do |app|
app::Models.module_eval $AR_EXTRAS
Camping::S.sub! /autoload\s*:Base\s*,\s*['"]camping\/db['"]/, ""
Camping::S.sub! /def\s*Y[;\s]*self[;\s]*end/, $AR_EXTRAS
Object.constants.map{|c|Object.const_get(c)}.each do |c|
c::Models.module_eval $AR_EXTRAS if c.respond_to?(:run)
end

0 comments on commit da3ed28

Please sign in to comment.