-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaketfu-speed.patch
More file actions
34 lines (30 loc) · 1.1 KB
/
paketfu-speed.patch
File metadata and controls
34 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Index: lib/packetfu/packetfu.rb
===================================================================
--- lib/packetfu/packetfu.rb (revision 15118)
+++ lib/packetfu/packetfu.rb (working copy)
@@ -77,6 +77,7 @@
end
@packet_classes ||= []
@packet_classes << klass
+ @packet_classes_dirty = true
@packet_classes.sort! {|x,y| x.name <=> y.name}
end
@@ -85,6 +86,7 @@
raise "Need a class" unless klass.kind_of? Class
@packet_classes ||= []
@packet_classes.delete klass
+ @packet_classes_dirty = true
@packet_classes
end
@@ -95,8 +97,11 @@
# Returns an array of packet types by packet prefix.
def self.packet_prefixes
- return [] unless @packet_classes
- @packet_classes.map {|p| p.to_s.split("::").last.to_s.downcase.gsub(/packet$/,"")}
+ return [] if @packet_classes.nil?
+ return @packet_class_prefixes if @packet_classes_dirty == false
+ @packet_classes_dirty = false
+ @packet_class_prefixes = @packet_classes.map {|p| p.to_s.split("::").last.to_s.downcase.gsub(/packet$/,"")}
+ return @packet_class_prefixes
end
# The current inspect style. One of :hex, :dissect, or :default