mirror of https://github.com/scrapy/scrapy.git
Merge pull request #1740 from scrapy/response-text-micro-optimize
[MRG+1] micro-optimize response.text
This commit is contained in:
commit
4c9a6ef3ce
|
|
@ -59,7 +59,12 @@ class TextResponse(Response):
|
|||
|
||||
def body_as_unicode(self):
|
||||
"""Return body as unicode"""
|
||||
# check for self.encoding before _cached_ubody just in
|
||||
return self.text
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
""" Body as unicode """
|
||||
# access self.encoding before _cached_ubody to make sure
|
||||
# _body_inferred_encoding is called
|
||||
benc = self.encoding
|
||||
if self._cached_ubody is None:
|
||||
|
|
@ -67,11 +72,6 @@ class TextResponse(Response):
|
|||
self._cached_ubody = html_to_unicode(charset, self.body)[1]
|
||||
return self._cached_ubody
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
""" Body as unicode """
|
||||
return self.body_as_unicode()
|
||||
|
||||
def urljoin(self, url):
|
||||
"""Join this Response's url with a possible relative url to form an
|
||||
absolute interpretation of the latter."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue