Clone
Gustaf Neumann <neumann@wu-wien.ac.at>
committed
on 04 Sep 17
Optimization for aliases
Optimized AliasAdd() and AliasGet() by avoiding the usage of
Tcl_SetVar2Ex() and Tcl_GetVar2Ex(). This change impro… Show more
Optimization for aliases

Optimized AliasAdd() and AliasGet() by avoiding the usage of

Tcl_SetVar2Ex() and Tcl_GetVar2Ex(). This change improves the

performance of AliasAdd() by ~20% and AliasGet() by 10%.

Strangely, Tcl does not provide an interface to the

Tcl_Obj-based TclObjUnsetVar2(), which is used internally

by Tcl_UnsetVar2()), such we could also avoid the latter.

Show less

2.2 + 34 more
openacs-4/.../tcl/xowiki-www-procs.tcl (+4 -4)
1168 1168         #
1169 1169         # Reset the name in error cases to the original one.
1170 1170         #
1171 1171         set :name [:form_parameter __object_name:signed,convert]
1172 1172       } else {
1173 1173         #
1174 1174         # We have no validation errors, so we can save the content.
1175 1175         #
1176 1176         :save_data \
1177 1177             -use_given_publish_date [expr {"_publish_date" in $field_names}] \
1178 1178             [::xo::cc form_parameter __object_name:signed,convert ""] $category_ids
1179 1179
1180 1180         #
1181 1181         # The data might have references. Perform the rendering here to compute
1182 1182         # the references instead on every view (which would be safer, but slower). This is
1183 1183         # roughly the counterpart to edit_data and save_data in ad_forms.
1184 1184         #
1185 1185         set content [:render -update_references all]
1186 1186         #:log "after save refs=[expr {[info exists :references]?${:references} : {NONE}}]"
1187 1187
1188           set redirect_method [:form_parameter __form_redirect_method:word "view"]
  1188         set redirect_method [:form_parameter __form_redirect_method:wordchar "view"]
1189 1189         #:log "redirect_method $redirect_method"
1190 1190
1191 1191         if {$redirect_method eq "__none"} {
1192 1192           return
1193 1193         } else {
1194 1194           if {$redirect_method ne "view"} {
1195 1195             set qp "?m=$redirect_method"
1196 1196           } else {
1197 1197             set qp ""
1198 1198           }
1199 1199           set url [:pretty_link]$qp
1200 1200           #
1201 1201           # The method query_parameter uses now "::xo::cc set_parameter ...."
1202 1202           # with highest precedence
1203 1203           #
1204 1204           set return_url [::${:package_id} query_parameter return_url:localurl $url]
1205 1205
1206 1206           #:log "${:name}: url=$url, return_url=$return_url"
1207 1207           ::${:package_id} returnredirect $return_url
1208 1208
1209 1209           return
1210 1210         }
1211 1211       }
1212 1212     } elseif {[:form_parameter __form_action ""] eq "view-form-data"
1213 1213               && ![info exists :__feedback_mode]
1214 1214             } {
1215 1215       #
1216 1216       # We have nothing to save (maybe everything is read-only). Check
1217 1217       # __feedback_mode to prevent recursive loops.
1218 1218       #
1219         set redirect_method [:form_parameter __form_redirect_method:word "view"]
  1219       set redirect_method [:form_parameter __form_redirect_method:wordchar "view"]
1220 1220       #:log "__redirect_method=$redirect_method"
1221 1221       return [:www-view]
1222 1222     } else {
1223 1223       #
1224 1224       # Build the input form and display the current values.
1225 1225       #
1226 1226       #:log "form_action is something different: <[:form_parameter __form_action {}]>"
1227 1227       if {[:is_new_entry ${:name}]} {
1228 1228         set :creator [::xo::get_user_name [::xo::cc user_id]]
1229 1229         set :nls_language [::${:package_id} default_locale]
1230 1230       }
1231 1231
1232 1232       #array set __ia ${:instance_attributes}
1233 1233       :load_values_into_form_fields $form_fields
1234 1234
1235 1235       foreach f $form_fields {
1236 1236         set ff([$f name]) $f
1237 1237       }
1238 1238
1239 1239       #
 
1387 1387     if {$formNode ne ""} {
1388 1388
1389 1389       if {[:exists_query_parameter "return_url"]} {
1390 1390         set return_url [:query_parameter return_url:localurl]
1391 1391       } else {
1392 1392         #
1393 1393         # When no return_url is specified and we edit a page different
1394 1394         # from the invoked page, we use the calling page for default
1395 1395         # redirection.  We do not want to redirect to some "embedded"
1396 1396         # object after the edit. This happens if one edits e.g. a page
1397 1397         # through a link.
1398 1398         #
1399 1399         if {[::xo::cc exists invoke_object]
1400 1400             && [::xo::cc invoke_object] ne [self]
1401 1401           } {
1402 1402           #:log "=== no return_url specified, using [::xo::cc url] or [[::${:package_id} context] url]"
1403 1403           set return_url [::xo::cc url]
1404 1404           set return_url [ad_urlencode_url $return_url]
1405 1405         }
1406 1406       }
1407         set m [:form_parameter __form_redirect_method:word "edit"]
  1407       set m [:form_parameter __form_redirect_method:wordchar "edit"]
1408 1408       set url [export_vars -no_base_encode -base [:action_url] {m return_url}]
1409 1409       #:log "=== setting action <$url> for form-action my-name ${:name}"
1410 1410       $formNode setAttribute action $url method POST role form
1411 1411       if {$has_file} {$formNode setAttribute enctype multipart/form-data}
1412 1412       Form add_dom_attribute_value $formNode class [${:page_template} css_class_name]
1413 1413     }
1414 1414
1415 1415     :set_form_data $form_fields
1416 1416     if {$disable_input_fields} {
1417 1417       #
1418 1418       # (a) Disable explicit input fields.
1419 1419       #
1420 1420       foreach f $form_fields {$f set_disabled true}
1421 1421       #
1422 1422       # (b) Disable input in HTML-specified fields.
1423 1423       #
1424 1424       set disabled [Form dom_disable_input_fields $rootNode]
1425 1425       #
1426 1426       # Collect these variables in a hidden field to be able to
1427 1427       # distinguish later between e.g. un unchecked checkmark and an