TAILIEUCHUNG - Extreme Programming in Perl PHẦN 10

bản đồ ghi một hash xác định tiền tố và hậu tố. Đối với các thẻ khác, các tiền tố và hậu tố được tính từ một tên đơn giản. Chúng tôi lập html được gọi là một lần khởi tạo để chuyển đổi ánh xạ từ khóa đơn giản (mảng) vào các hình thức tiền tố / hậu tố tổng quát hơn (hash) cho hiệu quả. | title 39 h1 39 attribution maps to a hash that defines the prefix and suffix. For the other tags the prefix and suffix is computed from a simple name. We added _to_html_compile which is called once at initialization to convert the simple tag mappings arrays into the more general prefix suffix form hashes for efficiency. Second SMOP Interpreter We extended _to_html_node to handle asymmetric prefixes and suffixes. The relevant bits of code are sub _to_html_compile my config @_ while my xml html each config config- xml prefix _toffitml_tags html 39 39 suffix _to_html_tags reverse @ html 39 39 if ref html eq 39 ARRAY 39 return config sub _to_html_node my tag tree @_ return HTML Entities encode tree unless tag die tag 39 unhandled tag 39 unless _TO_HTML- tag We ignore the attributes for now. shift @ tree return _TO_HTML- tag - prefix . _to_html tree . _TO_HTML- tag - suffix _to_html_compile makes _to_html_node simpler and more efficient because it no longer calls _to_html_tags with the ordered and reversed HTML tag name lists. Well I thought it was more efficient. After performance testing the version in Final Implementation turned out to be just as The unnecessary compilation step adds complexity without improving 13 Thanks to Greg Compestine for asking the questions What are the alternatives and how do you know is faster Copyright 2004 Robert Nagler All rights reserved nagler@ 159 performance. We added it at my insistence. I remember saying to Alex We might as well add the compilation step now since we ll need it later anyway. Yikes Bad programmer Write I m not going to need it one hundred times in your PDA. Even in pairs it s hard to avoid the evils of pre-optimization. Spike Solutions As long as I am playing true confessions I might as well note that I implemented a spike solution to this problem before involving my programming partners. A spike solution in XP is a prototype that you intend to throw away. I wrote a spike to see how

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.