Executing perl takes about 23ms (6ms if dumped with perlinc-static)
while parsing the same data from JSON takes just 1.2ms.
-all: sitemap.xml light.css plan.plp UPDATE data/digraphs.inc.pl data/unicode-cover.inc.pl data/countries.inc.pl data/browser data/termcol-xcolor.inc.pl data/digraphs-xorg.inc.pl word
+all: sitemap.xml light.css plan.plp UPDATE data/digraphs.inc.pl data/unicode-cover.inc.pl data/countries.inc.pl data/browser data/termcol-xcolor.inc.pl data/digraphs-xorg.inc.pl word cache
more: all
.PHONY: force # applied to download after 2 hours
more: all
.PHONY: force # applied to download after 2 hours
UPDATE: $(download)
$(call cmdsave,git log -1 --date=short --pretty="%ad %s")
UPDATE: $(download)
$(call cmdsave,git log -1 --date=short --pretty="%ad %s")
+cache: data/writing-latn.json
word: word/put.min.js data/wordlist.inc.pl data/wordlist.en.json data/wordlist.nl.json data/wordlist.ru.json data/wordpairs.json
word/put.js: $(download)
word: word/put.min.js data/wordlist.inc.pl data/wordlist.en.json data/wordlist.nl.json data/wordlist.ru.json data/wordpairs.json
word/put.js: $(download)
$(call cmdsave,$< $*)
data/word%.json: data/word%.inc.pl
$(call cmdsave,perl -MJSON=encode_json -E "print encode_json(do \$$ARGV[0])" ./$<)
$(call cmdsave,$< $*)
data/word%.json: data/word%.inc.pl
$(call cmdsave,perl -MJSON=encode_json -E "print encode_json(do \$$ARGV[0])" ./$<)
+data/%.json: %.inc.pl
+ $(call cmdsave,perl -MJSON=encode_json -E "print encode_json([ do \$$ARGV[0] ])" ./$<)
data/wordpairs.inc.pl: data/wordlist.version.txt
@perl -I. -MShiar_Sheet::DB -MData::Dump=pp -E 'say pp(Shiar_Sheet::DB->connect->select("word w JOIN word a ON w.id=a.ref" => "w.id, a.id", {"a.lang"=>undef})->map or exit 1)' >$@
data/wordpairs.inc.pl: data/wordlist.version.txt
@perl -I. -MShiar_Sheet::DB -MData::Dump=pp -E 'say pp(Shiar_Sheet::DB->connect->select("word w JOIN word a ON w.id=a.ref" => "w.id, a.id", {"a.lang"=>undef})->map or exit 1)' >$@
-rm data/browser/support.inc.pl
-rm data/browser/usage-wm.inc.pl
-rm data/browser/support.inc.pl
-rm data/browser/usage-wm.inc.pl
-.SECONDEXPANSION:
-
-data/writing-latn.inc.pl: tools/perlinc-static $$(@F)
- $(call cmdsave,$^)
-
sub Data {
my ($filename) = @_;
my @data = eval {
sub Data {
my ($filename) = @_;
my @data = eval {
+ open my $cache, '<:raw', "data/$filename.json"
+ or return do "$filename.inc.pl"; # silent fallback to original code
+ require JSON;
+ local $/; # slurp
+ return JSON::decode_json(readline $cache);
};
if ($! or $@ or !@data or !$data[0]) {
die ['Table data not found', $@ || $!];
};
if ($! or $@ or !@data or !$data[0]) {
die ['Table data not found', $@ || $!];
+++ /dev/null
-#!/usr/bin/env perl
-use 5.014;
-use warnings;
-
-use Data::Dumper;
-
-my @data = do $ARGV[0] or die $@;
-print Data::Dumper->new([\@data])->Terse(1)->Quotekeys(0)->Indent(1)->Dump;