Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Parser_fetchIfRef since it's obsolete #6411

Merged
merged 1 commit into from
Sep 29, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ var Parser = (function ParserClosure() {
var stream = lexer.stream;

// Parse dictionary.
var dict = new Dict(null);
var dict = new Dict(this.xref);
while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
if (!isName(this.buf1)) {
error('Dictionary key must be a name object');
Expand All @@ -355,7 +355,7 @@ var Parser = (function ParserClosure() {
}

// Extract the name of the first (i.e. the current) image filter.
var filter = this.fetchIfRef(dict.get('Filter', 'F')), filterName;
var filter = dict.get('Filter', 'F'), filterName;
if (isName(filter)) {
filterName = filter.name;
} else if (isArray(filter) && isName(filter[0])) {
Expand Down Expand Up @@ -416,10 +416,6 @@ var Parser = (function ParserClosure() {

return imageStream;
},
fetchIfRef: function Parser_fetchIfRef(obj) {
// not relying on the xref.fetchIfRef -- xref might not be set
return (isRef(obj) ? this.xref.fetch(obj) : obj);
},
makeStream: function Parser_makeStream(dict, cipherTransform) {
var lexer = this.lexer;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, note how this comment doesn't actually agree entirely with the code. Reading it, I'd expect the next line to read e.g. like this instead:

return (this.xref && isRef(obj) ? this.xref.fetch(obj) : obj);

var stream = lexer.stream;
Expand All @@ -429,7 +425,7 @@ var Parser = (function ParserClosure() {
var pos = stream.pos - 1;

// get length
var length = this.fetchIfRef(dict.get('Length'));
var length = dict.get('Length');
if (!isInt(length)) {
info('Bad ' + length + ' attribute in stream');
length = 0;
Expand Down Expand Up @@ -499,8 +495,8 @@ var Parser = (function ParserClosure() {
return stream;
},
filter: function Parser_filter(stream, dict, length) {
var filter = this.fetchIfRef(dict.get('Filter', 'F'));
var params = this.fetchIfRef(dict.get('DecodeParms', 'DP'));
var filter = dict.get('Filter', 'F');
var params = dict.get('DecodeParms', 'DP');
if (isName(filter)) {
return this.makeFilter(stream, filter.name, length, params);
}
Expand Down Expand Up @@ -532,8 +528,8 @@ var Parser = (function ParserClosure() {
return new NullStream(stream);
}
try {
if (params) {
params = this.fetchIfRef(params);
if (params && this.xref) {
params = this.xref.fetchIfRef(params);
}
var xrefStreamStats = this.xref.stats.streamTypes;
if (name === 'FlateDecode' || name === 'Fl') {
Expand Down