Changeset 52
- Timestamp:
- 08/20/09 12:02:47 (3 years ago)
- Files:
-
- tyrant_manager/extensions/our.lua (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tyrant_manager/extensions/our.lua
r51 r52 35 35 36 36 --- Filter out values so we don't insert duplicates 37 local se rach_val = LIST_DELIM .. current_value37 local search_val = LIST_DELIM .. current_value 38 38 local values = _tokenize(value, LIST_DELIM) 39 39 local filtered = {} 40 40 41 41 for i=1, #values do 42 if not string.match(se rach_val, LIST_DELIM .. values[i] .. LIST_DELIM) then42 if not string.match(search_val, LIST_DELIM .. values[i] .. LIST_DELIM) then 43 43 table.insert(filtered, values[i]) 44 44 end … … 51 51 52 52 values = filtered 53 value = table.concat(values, LIST_DELIM) .. LIST_DELIM54 53 55 54 --- Check if we should apply cleanup 56 local current_list = _current_list(current_value, nil) 57 local list_size = #current_list 58 59 --- If the size is too big then clean up in it 55 local list_size = char_count(search_val, LIST_DELIM) 60 56 list_size = list_size + #values 61 57 62 58 if list_size > (limit + 100) then 59 local current_list = _current_list(current_value, nil) 63 60 _list_cleanup(key, current_list, limit, #values) 64 61 end … … 139 136 _put(key, result) 140 137 end 138 139 function char_count(str, char) 140 if not str then 141 return 0 142 end 143 144 local count = 0 145 local byte_char = string.byte(char) 146 for i = 1, #str do 147 if string.byte(str, i) == byte_char then 148 count = count + 1 149 end 150 end 151 return count 152 end
