Question: What is a more efficient way to generate OEIS' "A161786" sequence?

The sequence A161786 consists of “primes with at least one digit appearing exactly four times in the decimal expansion”. Below is the Maple program given in that OEIS page:

use isdgctm = proc(n, d) local dgs, a, i ; dgs := convert(n, base, 10) ; a := [seq(0, j=0..9)] ; for i in dgs do a := subsop(i+1=op(i+1, a)+1, a) ; od: if convert(a, set) intersect {d} <> {} then true; else false; fi; end in for n from 1 to 10000 do p := ithprime(n) ; if isdgctm(p, 4) then printf("%d, ", p) ; fi; od: end: # R. J. Mathar, Jun 21 2009

The code above picks out primes having exactly four identical digits (determined by isdgctm(p, 4)) from the first 10,000 prime numbers. However, it's easy to check that this program is rather slow (It takes about 2.6s to execute it!). 
Actually, I would like to select such primes from pn, pn+1, pn+2, …, pn+m-1 (typically, n=1,000,000 and m=1,000,000), where pk denotes the k-th prime number, yet the original program failes to do so in twenty minutes. Part of the reason is that for long sequences, the efficiency can be critical. Therefore, I make a slight modification to the original code: 

A161786__0 := proc(m::nonnegint, n::posint := 1, ` $`)::'Vector'(prime):
	#(*
	    kernelopts(opaquemodules = false):
	# *)
	local p := ifelse(n = 1, 1, ithprime(n - 1)), vec := Vector('datatype' = prime);
	to m do
		if ormap(`=`, MultiSet(`convert/base`:-MakeSplit(length((p := nextprime(p))), 1, 10)(p)):-hash, 4) then
			vec ,= p
		fi
	od;
	vec
end:

Nevertheless, this version is still inefficient: 

time[real](A161786__0(10**6, 10**6));
 = 
                            182.414

Another choice is converting each of integers into a string: 

A161786__1 := proc(m::nonnegint, n::posint := 1, ` $`)::'Vector'(prime):
	options no_options:
	local p := ifelse(n = 1, 1, ithprime(n - 1)), vec := DEQueue();
	to m do
		if member(4, rhs~({StringTools['CharacterFrequencies'](nprintf("%d", (p := nextprime(p))), 'digit')})) then
			vec ,= p
		fi
	od;
	Vector([vec[]], 'datatype' = prime)
end:

This time the elapsed time is reduced to nearly two minutes: 

time[real](A161786__1(10**6, 10**6));
 = 
                            118.409

But can't this task be accomplished within (a quarter of) a minute in modern Maple? In other words, is there a way to make further improvement on the performance? (Note that the reference time a quarter of a minute is mesured using a adjusted version (i.e., ) of the Mma code provided in that OEIS page.) 

Please Wait...